jqgrid can't load specific page during reload data from server side

喜夏-厌秋 提交于 2019-12-04 15:38:14

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!