title: jqGrid - server side pager
body: <p>I am stuck with this issue and will appreciate any help... (Oleg, are you here????)</p>
  
  <p>I have a jqgrid that does sorting, searching on server side, i know need to have pagination also done on the server, i found the webService method that will do that, but when i click on any of the paging buttons nothing happens and the call is not sent to the server.</p>
  
  <p>Can any one help me please and see what i have wrong in my code???</p>
  
  <p>My code is the  fallow:</p>
  
  <pre><code>$(myGrid).jqGrid({
      datatype: function (pdata) {
          Invoke("GetAll", pdata);
      },
      colNames: columnNames,
      colModel: columnModel,
      jsonReader: {
          root: "Result",
          page: "page",
          total: "total",
          records: "records"
      },
      rowNum: 10,
      //rowList: [5, 10, 20, 30],
      pager: '#ViewNQueryPager',
      viewrecords: true,
      shrinkToFit: true,
      loadtext: "Loading....",
      emptyrecords: "No records to view",
      viewrecords: true,
      //scrollOffset: 0,
      height: '300',
      //width: '100%',
      ignoreCase: true,
      sortname: 'ID',
      sortable: true,
      sortorder: 'asc',
      grouping: true,
      groupingView: {
          groupField: ['ID']
      }
  });
  $(myGrid).jqGrid('navGrid', '#ViewNQueryPager', { del: false, add: false, edit: false }, {}, {}, {}, { multipleSearch: true, multipleGroup: true, showQuery: true, onSearch: function (response) { showQueryDetails(); } });
  $(myGrid).jqGrid('filterToolbar', { stringResult: true, searchOnEnter: true });
  $(myGrid).fluidGrid({ base: '#tableBox', offset: -20 });
  
  function Invoke(action, pdata) {
  
      var request = new Object();
      if (pdata.filters == undefined &amp;&amp; pdata._search == false)
          request.Action = "Sort";
      else {
          if (pdata.filters != undefined &amp;&amp; pdata._search == false)
              request.Action = action;
          else request.Action = "Filter";
      }
      if (pdata) {
          request.SortIndex = pdata.sidx;
          request.SortOrder = pdata.sord;
          request.PageNumber = pdata.page;
          request.PageSize = pdata.rows;
          request._search = pdata._search;
          request.filters = pdata.filters;
      }
  
      var cRequest = new Object();
      cRequest.request = request;
  
      $.ajax({
          type: "POST",
          contentType: "application/json; charset=utf-8",
          url: 'WebService.asmx/Get',
          ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
          dataType: "json",
          data: JSON.stringify(cRequest),
          success: function (xhrResponse, textStatus) {
              var data = xhrResponse.d;
              var table = $('#ViewNQueryTable');
              table.clearGridData();
              //table.total = data.total;
  
              for (var i = 0; i &lt; data.Result.length; i++) {
                  table.addRowData(i + 1, data.Result[i], 'last');
              }
              $('#totalRecordsFound').html(data.records + " Customers");
              pdata.filters = undefined;
              pdata._search = false;
          },
          error: function (data, textStatus) {
              alert("Error fetching data");
          }
      });
  }
  </code></pre>
  
  <p>I tried adding this:</p>
  
  <pre><code>onPaging: function (which_button) {
          doSomething()
      } 
  </code></pre>
  
  <p>But it didnt help.</p>
  
  <p>How can i get the paging buttons to call the server method?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>My web method is this:</p>
  
  <pre><code>[WebMethod]
  public kResponse Get(kRequest request)
  {
      if (count == 0)
      {
          CurrentList = JsonHelper.GetPersons();
          count++;
      }
  
      var response = new kResponse();
  
      switch (request.Action)
      {
          case "GetAll":
              var result = new List&lt;Person&gt;();
              var list = JsonHelper.GetPersons();
              CurrentList = list;
              response.records = CurrentList.Count;
              response.total = response.records / request.PageSize;
              //response.total = list.Count;
              response.page = request.PageNumber;
              for (int i = 0; i &lt; 10; i++)
              {
                  result.Add(list[i]);    
              }
  
              //response.Result = result;
              response.Result = list;
  
              break;
          case "Filter":
              var filterParams = Filter.Create(request.filters);
              List&lt;Person&gt; FilterdList = GetFilteredList(filterParams);
              CurrentList = FilterdList;
              response.Result = CurrentList;
              response.records = CurrentList.Count();
              response.total = response.records / request.PageSize;
              //response.total = list.Count;
              response.page = request.PageNumber;
              break;
  
          case "Sort":
              //var listPersons = JsonHelper.GetPersons();
              IQueryable&lt;Person&gt; SortedList = ApplySort(CurrentList.AsQueryable(), request.SortIndex, request.SortOrder);
              CurrentList = SortedList.ToList();
              response.Result = CurrentList;
              response.records = CurrentList.Count();
              response.total = response.records / request.PageSize;
              //response.total = list.Count;
              response.page = request.PageNumber;
              break;
          case "NextPage":
              List&lt;Person&gt; allList = JsonHelper.GetPersons();
              IQueryable&lt;Person&gt; NextPagelist = allList.AsQueryable();
              NextPagelist = NextPagelist.Skip(request.PageNumber * request.PageSize).Take(request.PageSize).AsQueryable();
              response.Result = NextPagelist;
              response.records = NextPagelist.Count();
              response.total = response.records / request.PageSize;
              //response.total = list.Count;
              response.page = request.PageNumber++;
  
  
              break;
      }
      return response;
  }
  </code></pre>
  
  <p>with the class:</p>
  
  <pre><code>public class kRequest
  
  public string Action { get; set; }
  public int PageSize { get; set; }
  public int PageNumber { get; set; }
  public string SortIndex { get; set; }
  public string SortOrder { get; set; }
  public string Search { get; set; }
  public bool _search { get; set; }
  
  public string filters { get; set; }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>public class kResponse
  
  //public int Total { get; set; }
  public object Result { get; set; }
  public int page { get; set; }
  public int total { get; set; }
  public int records { get; set; }
  //public GridRow[] rows { get; set; }
  </code></pre>
  
  <p>for doing the pager i am trying this:</p>
  
  <pre><code>$('#next_ViewNQueryPager').click(function () {
  
      grid.Action = "NextPage";
      triggerReloadGrid();
  
  });
  </code></pre>
  
  <p>but i am sure this is not the way... what is??</p>