title: jQuery JQGrid pagination event
body: <p>Am new to jQuery and don't know how to implement jQuery JqGrid pagination event.
  Actual requirement is ,on change of page i have to get some records from database.
  So for that i need to know how to implement Jqgrid pagination event.</p>
  
  <p><strong>Getting error @ Line:var currentPage = $('#gridData').getGridParam('page'); //get current  page</strong></p>
  
  <p>Error Msg:0x800a01b6 - microsoft jscript runtime error object doesn't support this property or method.
  Below is the code for reference. </p>
  
  <pre><code>$("#gridData").jqGrid({
                  data: selectedTblData.Table.Rows,
                  datatype: "local",
                  toppager: true,
                  height: "100%",
                  width: (selectedTblData.Table.Width &lt; 1000) ? 985 : "100%",
                  altRows: true,
                  altclass: "custom-alt-row",
                  colNames: selectedTblData.Table.colNames,
                  colModel: selectedTblData.Table.colModel,
                  multiselect: false,
                  rowNum: 25,
                  rowList: [15, 25, 50, 75, 100],
                  mtype: 'GET',
                  pager: '#pager',
                  sortname: selectedTblData.Table.colNames[0],
                  sortorder: "asc",
                  viewrecords: true,
                  shrinkToFit: (selectedTblData.Table.Width &lt; 1000),
                  caption: tableName,
                  secureUri: false,
                  contentType: "application/json; charset=utf-8",
                  loadonce: true,
                  //BS Page start
                  onPaging: function (pgButton) {
                      //debugger;
  
  
                      var pagerId = this.p.pager.substr(1); // get paper id like "pager"
                      var currentPage = $('#gridData').getGridParam('page'); //get current  page
                      var lastPage = $("#gridData").getGridParam("lastpage"); //get last page 
  
                  if (currentPage - 1 == lastPage - 1)
                      $("#gridData").setGridParam({ page: lastPage }).trigger("reloadGrid"); // set the requested page to the last page value – then reload
  
                  var currentRecordCount = $("#gridData").getGridParam("reccount");  //get the record count
                  var recordsPerPage = $("#gridData").getGridParam("rowNum");  // get the records per page
                  var newValue = 0;  // new value
                  if (pgButton === "user") {
                      newValue = $(".ui-pg-input").val(); 
                  }
                  else {
  
                      if (pgButton.indexOf("next") &gt;= 0)
                          newValue = ++currentPage;
                      else if (pgButton.indexOf("prev") &gt;= 0)
                          newValue = --currentPage;
                      else if (pgButton.indexOf("last") &gt;= 0)
                          newValue = $("#gridId").getGridParam('lastpage');
                      else if (pgButton.indexOf("first") &gt;= 0)
                          newValue = 1;
                  }
                      alert(newValue);
                      $("#gridData").setGridParam({ page: newValue }).trigger("reloadGrid");  // set the requested page to the last page value – then reload
                      currentRecordCount = $("#gridData").getGridParam("reccount");  // read the current page records
                      alert('RecordCount: ' + currentRecordCount + ' RecordsPerPage: ' + recordsPerPage);
  
                  if (currentRecordCount &lt; recordsPerPage) {
                      startRange = 1;
                      endRange += endRange;
  
                      jQuery("#gridData").jqGrid("setGridParam", { datatype: "json", data: "{TableName :'" + tableName + "'}", url: "TablesCoolView.aspx/GetTableData" }).trigger("reloadGrid");
                  }
              }
                  //BS page end
              });
  </code></pre>
  
  <p>Please help me out of this.</p>