You misunderstand how a grid is built. A grid can contain hidden columns, but no hidden rows . If the body of the entire grid is deleted in one filter grid and only filtered rows are inserted.
The setRowData
method can be used to change any grid line, but you cannot change something that is missing in the grid.
If you use a local grid ( datatype: 'local'
), then the data you save in the grid will be stored in the two internal parameters jqGrid data
and _index
. Therefore, you must modify the data
object. To fill the grid with the modified data
, you need to call .trigger("reloadGrid")
.
So, if you want to change the item_id
, item
and item_cd
of the grid data for rowid = 2, you can take the following steps.
1) Get links to jqGrid data
and _index
internal parameters:
var $myGrid = jQuery("#toolbar"), data = $myGrid.jqGrid('getGridParam', 'data'), index = $myGrid.jqGrid('getGridParam', '_index');
2) Get a reference to the object that represents the required rowid:
var rowId = '2', itemIndex = index[rowId], rowItem = data[itemIndex];
3) Change the data item as you need:
rowItem.item_id = 2; rowItem.item = 'blargh'; rowItem.item_cd = 12345678;
4) Refresh the grid (if necessary) by reloading the grid
$myGrid.trigger('reloadGrid');