Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have implemented server side paging with client side sorting. Everything works fine but Total record is not setting properly in pager and next prev button dont work.

next, prev button is not active. I get data from database according to page.

For ex : if i am on 1st page so i get 10 record to display in grid and so on if user click next to go next page it will show next 10 record from db.

But problem is next button is not visible also total is also not showing.

Following are my json .

HTML
{"total":10,"page":1,"records":100,"rows":[

{"id":0,"cell":["1","false","1","Module 1 - Title"]},
{"id":1,"cell":["2","false","1","Introduction"]},
{"id":2,"cell":["3","false","1","What is Asbestos?"]},
{"id":3,"cell":["4","false","1","Asbestos in Construction"]},
{"id":4,"cell":["5","false","1","Asbestos Materials"]},
{"id":5,"cell":["6","false","1","Health Hazards"]},
{"id":6,"cell":["7","false","1","Asbestosis"]},
{"id":7,"cell":["8","false","1","Asbestos Regulations"]},
{"id":8,"cell":["9","false","1","Ontario Regulation 278/05"]},
{"id":9,"cell":["10","false","1","Asbestos Management Program"]}
]
}


and following are my method to get json to grid. GRid is bindind properly

HTML
function fn_getData() {
  $("#gvStock").jqGrid({
    url: 'jqgrid_server_side_paging.aspx?a=1',
    datatype: "json",
    loadError: function (xhr, status, error) {
      alert('load error: ' + error);
    },
    colNames: ['idtrainingeventresistrationresult', 'course_status', 'course_attempts', 'title', 'Edit', 'Delete'],
    colModel: [
                    { name: 'idtrainingeventresistrationresult', index: 'idtrainingeventresistrationresult', align: 'center', sortable: true, sorttype: 'integer' },
                { name: 'course_status', index: 'course_status', align: 'left', sortable: true, sorttype: 'text' },
                { name: 'course_attempts', index: 'course_attempts', align: 'center', sortable: true, sorttype: 'integer' },
                { name: 'title', index: 'title', align: 'center', sortable: true, sorttype: 'text' },
                { formatter: fn_Edit, align: 'left', sortable: false },
                { formatter: fn_Delete, align: 'left', sortable: false },
    ],
    loadonce: true,
    treeGridModel: 'adjacency',
    mtype: 'GET',
    loadonce: true,
    rowList: [10, 20, 30, 40, 50],
    pager: '#jQGridPager1',
    pginput: true,
    height: "auto",
    width: 930,
    rownumWidth: 20,
    rowNum: 10,
    shrinkToFit: true,
    rownumbers: false,
    viewrecords: true,
    caption: "Server side paging with client side sorting",
    gridComplete: function () {
      var recs = $("#gvStock").getGridParam("records");
      if (recs == 0 || recs == undefined) {
        $("#nd1").show();
      }
      else {
        $("#nd1").hide();
      }
    },

    loadComplete: function () {
      $("#gvStock").setGridParam({ datatype: 'local' });
      $("th.ui-th-column").css("font", "bold"); $("tr.jqgrow:odd").css("background", "#E7E7FF");
    },

    jsonReader: { repeatitems: true, root: "rows", page: "page", total: "total", records: "records", cell: "cell", id: "id", },

    onPaging : function(which_button) {
      $("#gvStock").setGridParam({ datatype: 'json' });
    }
  });
}



Please suggest where i am wrong.
Posted
Updated 30-Aug-18 20:42pm

1 solution

change loadonce property from true to false because when we use loadonce it loads the data only once it is only used for client side scripting
 
Share this answer
 
v2
Comments
Blutfaust 31-Aug-18 12:21pm    
Only three years too late

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900