Dinesh
Dinesh

Reputation: 2066

JQGrid paginator's textbox is not working

My JQGrid's Paginator not working as expected. Navigation buttons are working fine. But when enter the page number manually and pressed enter key, it is not working. I have tried all the possible options. But still it is not working. Can somebody help me to identify the issue.

Here is my grid creation code:

$("#ptSPSDataGrid").jqGrid({
        datatype: 'local',
        data: localdata,
        colModel: colmod,
        rowNum: 10,
        rowList: [10, 25, 50],
        pager: '#ptSPSPager',
        page: 1,
        gridview: true,
        rownumbers: false,
        viewrecords: true,  
        altRows:  true,        
        loadtext: "Loading parts data...", 
        caption: 'Part Data',
        width: 713,
        shrinkToFit: false,
        scrollOffset: 0,
        height: '100%',
        loadComplete: function() {
            $("#ptSPSDataGrid").trigger("reloadGrid"); // Call to fix client-side sorting
        } 
    }); 
$("#ptSPSDataGrid").jqGrid('navGrid', '#ptSPSPager', { add: false, edit: false, del: false, search: false, refresh: false });
            $("#ptSPSDataGrid").jqGrid('navButtonAdd', '#ptSPSPager', {
                caption: "Show/Hide Columns",
                title: "Click here to select the columns to view",
                onClickButton: function () { //Adding some code
                 },
        position: "last"
    });

Upvotes: 0

Views: 538

Answers (1)

Oleg
Oleg

Reputation: 221997

I think the problem is in the lines

loadComplete: function() {
    $("#ptSPSDataGrid").trigger("reloadGrid"); // Call to fix client-side sorting
}

The event reloadGrid reset the page parameter to 1 if you not explicitly set additional parameter (see the answer).

What you probably want to do is to trigger reload only once. So you can change the code to something like

var firstLoad = true;

$("#ptSPSDataGrid").jqGrid({
    datatype: 'local',
    data: localdata,
    ... // other parameters
    loadComplete: function () {
        if (firstLoad) {
            $(this).trigger("reloadGrid"); // Call to fix client-side sorting
            firstLoad = false;
        }
    } 
});

Upvotes: 1

Related Questions