jQuery jqGrid分页问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3807623/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jqGrid paging question
提问by Marcus Leon
If you have 17 records and are displaying 15 at a time then when you're on page 2 you see records 16-17 of 17 - makes sense.
如果您有 17 条记录并且一次显示 15 条,那么当您在第 2 页上时,您会看到 17 条记录中的第 16-17 条 - 很有意义。
Now when you're on this second page and you hit the reload button on the nav (set datatype='json') when the grid reloads the nav is showing that the grid is displaying 16-30 of 17. This seems to be a bug - is there a workaround?
现在,当您在第二页上并点击导航上的重新加载按钮(设置 datatype='json')时,当网格重新加载时,导航显示网格显示 17 个中的 16-30 个。这似乎是一个错误 - 有解决方法吗?
The grid still has 17 rows - but it's trying to show a full 15 rows (the rowNum) setting on the second page when it should only be showing two rows (16-17). And the nav pagination text is incorrect (referring to 30 rows when there is only 17).
网格仍然有 17 行 - 但它试图在第二页上显示完整的 15 行(rowNum)设置,而它应该只显示两行(16-17)。并且导航分页文字不正确(只有17行时指30行)。
回答by Oleg
You are right. It is an old problem. I used always before
你是对的。这是一个老问题。我以前一直用
$("#list").setGridParam({page:1}).trigger('reloadGrid');
but there is another way. The trigger 'reloadGrid' support additional options: 'current' and 'page'.
但还有另一种方式。触发器“reloadGrid”支持附加选项:“current”和“page”。
$("#list").trigger("reloadGrid", [{page:1}]);
will reset page
to 1 in one step. The usage in the form
将page
一步重置为 1。表格中的用法
$("#list").trigger("reloadGrid", [{current:true}]);
allows to preserver current selection. You can of cause combine both options.
允许保留当前选择。您当然可以结合使用这两个选项。