tonytomov/jqGrid — Issue #235: datatype='local' and paging doesn't work
Author: RobinHerbots
Created: 2012-01-04 22:57:04+00:00
State: open

scenario:

Create a jqGrid with local data; 10 items without paging.
call a getRowData with rowid 7 or do a setdata for rowid7 => all works fine

The same grid with paging, with rrowNum:5,	rowList:[5,10,15], => goto the second page
call a getRowData with rowid 7 or do a setdata for rowid7 => all results in nothing

This is because for ex in getRowData

you try to find the data by .... ind = $t.rows.namedItem(rowid); ....

but $t.rows contains only 5 rows and rowid 7 doesn't exist anymore
you can fix getRowData by something like

ind = $t.rows.namedItem($t.p.datatype=='local' ? rowid % $t.p.rowNum : rowid);
but this only solves the problem when the actual row is visible on the grid
and in setRowData, delRowData, ... we have the same issue
should this be fixed in all impacted functions or should this be fixed somewhere else.

some other remark why isn't the p._index populated when using datatype='local', this can by fixed in addLocalData or in addJSONData

ex in addJSONData:
...
if(ts.p.datatype == "local") {
dReader = ts.p.localReader;
frd= 'local';
//init id indexes for initial local data
ts.p._index = {};
for(var i=0, dl = ts.p.data.length; i < dl; i++){
var cur = ts.p.data[i], idr = (ts.p.scroll ? $.jgrid.randId() : 1)+i;
cur[locid] = idr;
ts.p._index[idr] = i;
}
}

also see my pull request 184