0

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"
    });
Dinesh
  • 2,026
  • 7
  • 38
  • 60

1 Answers1

1

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;
        }
    } 
});
Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798