Finding current page number in jqGrid
Asked Answered
F

3

19

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.

Federicofedirko answered 28/8, 2009 at 22:31 Comment(0)
D
42

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
Disastrous answered 29/8, 2009 at 1:5 Comment(0)
M
5

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.

Merkle answered 6/8, 2013 at 16:40 Comment(0)
M
2

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);
Malonylurea answered 9/1, 2014 at 9:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.