title: jQGrid not showing last page and total records returned from server
body: <p>I'm using jQGrid with asp handler to display records in grid. Everything working fine with client side paging, searching and sorting. Below is my code.</p>
  
  <pre><code>jQuery("#jQGridDemo").jqGrid({
              url: 'http://localhost:58404/JQGridHandler.ashx',
              datatype: "json",
              colNames: ['Id', 'First Name', 'Last Name', 'Last 4 SSN', 'Department', 'Age', 'Salary', "Address", 'Marital Status'],
              colModel: [
                          { name: '_id', index: '_id', width: 50, stype: 'text' },
                          { name: 'FirstName', index: 'FirstName', width: 100, stype: 'text', sortable: true, editable: true },
                          { name: 'LastName', index: 'LastName', width: 100, editable: true },
                          { name: 'LastSSN', index: 'LastSSN', width: 100, editable: true },
                          { name: 'Department', index: 'Department', width: 100, align: "right", editable: true },
                          { name: 'Age', index: 'Age', width: 40, align: "right", editable: true },
                          { name: 'Salary', index: 'Salary', width: 100, align: "right", editable: true },
                          { name: 'Address', index: 'Address', width: 100, sortable: false, editable: true },
                          { name: 'MaritalStatus', index: 'MaritalStatus', width: 100, sortable: false, editable: true }
                        ],
              rowNum: 10,
              mtype: 'GET',
              loadonce: true,
              rowList: [10],
              pager: '#jQGridDemoPager',
              sortname: '_id',
              viewrecords: true,
              sortorder: 'asc',  //desc
              caption: "List Student Details",
              editurl: 'http://localhost:58404/JQGridHandler.ashx'
              //// ****** here i placed the onPaging: //.......
          });
  
          $('#jQGridDemo').jqGrid('navGrid', '#jQGridDemoPager',
                     {
                         edit: true,
                         add: true,
                         del: true,
                         search: true,
                         searchtext: "Search",
                         addtext: "Add",
                         edittext: "Edit",
                         deltext: "Delete"
                     },
                     {   //EDIT
                         //                       height: 300,
                         //                       width: 400,
                         //                       top: 50,
                         //                       left: 100,
                         //                       dataheight: 280,
                         closeOnEscape: true,     //Closes the popup on pressing escape key
                         reloadAfterSubmit: true,
                         drag: true,
                         afterSubmit: function (response, postdata) {
                             if (response.responseText == "") {
  
                                 $(this).jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid'); //Reloads the grid after edit
                                 return [true, '']
                             }
                             else {
                                 $(this).jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid'); //Reloads the grid after edit
                                 return [false, response.responseText]//Captures and displays the response text on th Edit window
                             }
                         },
                         editData: {
                             EmpId: function () {
                                 var sel_id = $('#jQGridDemo').jqGrid('getGridParam', 'selrow');
                                 var value = $('#jQGridDemo').jqGrid('getCell', sel_id, '_id');
                                 return value;
                             }
                         }
                     },
                     {
                         closeAfterAdd: true,     //Closes the add window after add
                         afterSubmit: function (response, postdata) {
                             if (response.responseText == "") {
  
                                 $(this).jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid')//Reloads the grid after Add
                                 return [true, '']
                             }
                             else {
                                 $(this).jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid')//Reloads the grid after Add
                                 return [false, response.responseText]
                             }
                         }
                     },
                     {   //DELETE
                         closeOnEscape: true,
                         closeAfterDelete: true,
                         reloadAfterSubmit: true,
                         closeOnEscape: true,
                         drag: true,
                         afterSubmit: function (response, postdata) {
                             if (response.responseText == "") {
  
                                 $("#jQGridDemo").trigger("reloadGrid", [{ current: true}]);
                                 return [false, response.responseText]
                             }
                             else {
                                 $(this).jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid')
                                 return [true, response.responseText]
                             }
                         },
                         delData: {
                             EmpId: function () {
                                 var sel_id = $('#jQGridDemo').jqGrid('getGridParam', 'selrow');
                                 var value = $('#jQGridDemo').jqGrid('getCell', sel_id, '_id');
                                 return value;
                             }
                         }
                     },
                     {//SEARCH
                         closeOnEscape: true
  
                     }
              );
  </code></pre>
  
  <p>Now I need server side paging and tried with the code <a href="https://stackoverflow.com/questions/9030302/jqgrid-client-side-sorting-with-server-side-paging-data-disappears/9047197#9047197">answer</a> by Oleg. I placed that cod in jqgrid under editurl.</p>
  
  <pre><code>onPaging: function (which_button) {
                  var pageNumber = $(this).jqGrid("getGridParam", "page");
                  $(this).setGridParam({ datatype: 'json', page: pageNumber }).triggerHandler("reloadGrid");
              },    
              loadComplete: function (data) {
                  var $this = $(this);
                  if ($this.jqGrid('getGridParam', 'datatype') === 'json') {
                      $this.jqGrid('setGridParam', {
                          datatype: 'local',
                          data: data.rows,
                          page: data.page,
                          records: data.totalRecords,
                          total: data.total
                      });
                      this.refreshIndex();
  
                      if ($this.jqGrid('getGridParam', 'sortname') !== '') {
                          $this.triggerHandler('reloadGrid');
                      }
                  } else {
                      $this.jqGrid('setGridParam', {
                          page: $this.jqGrid('getGridParam', 'pageServer'),
                          records: $this.jqGrid('getGridParam', 'recordsServer'),
                          lastpage: $this.jqGrid('getGridParam', 'lastpageServer')
                      });
                      this.updatepager(false, true);
                  }
              }
  </code></pre>
  
  <p>In loadComplete data contains the no. of records per page, and and displayed. but grid not showing the total recods returned from server. It's showing <code>view 11 - 20 of 10</code>.
  I'm also getting total records from server in <code>data.totalRcords</code>.</p>
  
  <p>Is it correct place where i placed the <code>onPaging</code>?
  Oleg, I'm new to jqgrid put me in right direction.</p>
  
  <p>Thanks!</p>