How to get the page number from the JQGrid Paginat

2019-02-20 13:35发布

I have JQGrid in my application. If i wanted to capture the user input from Pagination's page number text box, what i have to do? And also i wanted to do it before grid changes it's page.

Is there any way to do it? Please, somebody help me to implement this.

2条回答
混吃等死
2楼-- · 2019-02-20 14:23

You can use onPaging callback If is's needed you can event stop changing of the page. In case of direct user input the parameter of callback will be the string "user". To get the current value you can use either page parameter or get or set the value directly from the input control

onPaging: function (pgButton) {
    var pagerId = this.p.pager.substr(1); // ger paper id like "pager"
    var newValue = $('input.ui-pg-input', "#pg_" + $.jgrid.jqID(pagerId)).val();
        // newValue is in the most cases the same as in this.p.page
        // only wrong values like -10 entered by user will not update
        // "page" parameter
    if (pgButton === "user" && newValue > 2) { // some tests
        return "stop";
    }
}

UPDATED: Free jqGrid don't have the described above problem. See the wiki article which describes additional options parameter of onPaging callback, which has newPage, currentPage and some other properties.

查看更多
做自己的国王
3楼-- · 2019-02-20 14:39

I was facing same problem. I need to pass page number manually. I found this code from another post I dont remeber :p.

Hope it will be help full

$("#GridId").getGridParam('page')
查看更多
登录 后发表回答