free-jqgrid: getLocalRow return false in free-jqgr

2019-01-29 10:46发布

enter image description hereWe were using below code in jqgrid 4.3. Now I am upgrading to 4.13.6. The below code was working in 4.3, but in 4.13, it return false... Any help please...

var grid = $("#myGrid").jqGrid('getRowData');
$.each(grid, function(key, value) {
    selectedRow = key+1;
    var rowData = $("#myGrid").jqGrid('getLocalRow', selectedRow);
});

I am not using any id while filling my grid. datatype: json, rownumbers: true.

When I debug, I see the ID of each rows are 'jqg41', 'jqg42' etc... And sometimes it is 'jqg61', 'jqg62' etc... It is a random number which is appended after 'jqg'

some more code (but not completed code)

$grid.jqGrid({
                    datatype: 'json',
                    url: 'myUrl/byFileId.do?custId='+custId,
                    mtype: 'GET',
                    ajaxSubgridOptions: { async: false },
                    colNames:[ col1, col2 ...],
                    colModel:[    
                        . . .
                        . . .
                        . . .
                    ],  
                    headertitles:true,
                    rowNum:999,
                    rowList:[],
                    pager: '',
                    records: 1000,
                    pgbuttons : false,
                    viewrecords : false,
                    pgtext : null,
                    pginput : false,
                    gridview:true,
                    ignoreCase:true,
                    rownumbers:true,
                    sortname: 'invdate',
                    viewrecords: true,
                    sortorder: 'desc',
                    multiselect: true, 
                    caption: "Customer Search Result",
                    height: '100%',
                    editurl: 'clientArray',
                    autoencode: true,
                    loadonce: true,
                    multiselectWidth: 30,
                    width: rmtPageTitleWidth,
                    viewsortcols : [true,'vertical',true],
                    onSortCol: function (index, idxcol, sortorder) {
                        rowIdAndNoOfRowPair = [];
                        if (this.p.lastsort >= 0 && this.p.lastsort !== idxcol
                                && this.p.colModel[this.p.lastsort].sortable !== false) {
                            $(this.grid.headers[this.p.lastsort].el).find(">div.ui-jqgrid-sortable>span.s-ico").show();
                        }
                    },

enter image description here

1条回答
家丑人穷心不美
2楼-- · 2019-01-29 11:13

You can just use

var localData = $("#myGrid").jqGrid("getGridParam", "data");

to get all local data as an array. It's the reference to internal data of jqGrid.

UPDATED: If the grid is sorted or filtered locally and want to get the data from all rows in the same order, then you should get lastSelectedData parameter instead of data. You can force sorting the data locally after loading from the server by usage forceClientSorting: true parameter of jqGrid additionally to loadonce: true.

The demo https://jsfiddle.net/OlegKi/akv51mdq/ demonstrates lastSelectedData in case of local data, which has no id information. Another demo https://jsfiddle.net/OlegKi/Ljejoh21/ do the same with the data loaded from the server at once.

查看更多
登录 后发表回答