I suppose that you use loadonce: true
parameter. To reload the data from the server you set datatype
: to 'json' (I hope that you use setGridParam({datatype:'json'})
and not setGridParam({datatype:json})
like it is in the code fragment from the question). After the data will be loaded from the server the first page of the local data will be displayed.
To solve the problem you will have to reload the grid one more time inside of loadComplete
, but now you should reload the local grid. To have no reloading loop and to allow local paging you should verify whether the current datatype
is 'json':
var myGrid = $("#mygrid"), currentPage = 1;
...
myGrid.jqGrid({
// all grid parameters and additionally the following
loadComplete: function() {
if (this.p.datatype === 'json' && currentPage !== 1) {
setTimeout(function() {
myGrid.trigger("reloadGrid",[{page:currentPage}]);
}, 50);
}
}
});
....
currentPage = 5;
myGrid.setGridParam({datatype:'json'}).trigger("reloadGrid",[{page:currentPage}]);
See the demo here.