Finding current page number in jqGrid

爱⌒轻易说出口 提交于 2020-01-23 04:21:15

问题


How can I find the current page number in jqGrid (using jQuery of course). Also how do I know how many pages are there in total.


回答1:


This should do it:

$("#sp_1").text(); // total pages

$(".ui-pg-input").val(); // current page

Edit: I found a better way in the docs for the current page but I didn't see anything for the total page count. (Click Manipulating -> Get Methods)

$('#your_grid').getGridParam('page'); // current page



回答2:


this is an old question but it might help someone,

$("#"+gridId).getGridParam('lastpage')

will give the last page, which is the total too. Its useful to use firebug and

console.log($("#"+gridId).getGridParam());

which will show all the gridParams accessible.




回答3:


About last page in grid, the best way is to use jqGrid - docs. In this case:

jQuery("#gridID").getGridParam('pgtext');

And if you have only 1 page, the result should be

"Page {0} of {1}"

from jqGrid wiki:

pgtext -> string -> Show information about current page status. The first value is the current loaded page. The second value is the total number of pages.

Another way is to get all records and divide to records on page:

var rowNum = jQuery("#gridID").getGridParam('rowNum');
var allRecords = jQuery("#gridID").getGridParam('records');
var totalPages = parseInt((allRecords / rowNum) + 1);


来源:https://stackoverflow.com/questions/1349700/finding-current-page-number-in-jqgrid

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