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.
Finding current page number in jqGrid
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
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.
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);
© 2022 - 2024 — McMap. All rights reserved.