Simple question, hard to find an answer:
If I try to select a row programmatically, I use this:
$('#grid').jqGrid('setSelection', rowId);
The problem is that it only selects rows on current visible page. If rowId is on another page, it will not be selected.
More info: My goal is to select multiple rows (spread on multiple pages) when page loads for the first time.
Thanks, Rafael
PS: This guy has the same problem. No answer yet: jqgrid multiselect only selects rows on the current page, if paging is enabled. How to make it select rows across pages?
Right, jqGrid will only select rows on the current page. In order to select other rows you need to maintain a list of selected ID's and manually select them.
To do this you need to add code to your loadComplete
event to search the current page and select any of these rows:
var ids = grid.jqGrid('getDataIDs');
for (var i = 0; i < ids.length; i++){
if (selected[ids[i]] === true ){
grid.setSelection(ids[i], false);
}
}
You also need to add code to your onSelectRow
and onSelectAll
events to adjust the contents of selected
when the user selects/unselects rows:
onSelectRow: function(rowid, status){
selected[rowid] = status;
setSelectedDeviceCount();
},
onSelectAll: function(rowids, status){
for (var i = 0; i < rowids.length; i++){
selected[rowids[i]] = status;
}
}
Does that help?