title: jqGrid : deleting last record dosen't refresh the grid + trouble with paging
body: <p>I 've two problems in jqGrid</p>
  
  <p>1) Suppose there is 91 records in table with rownum set to 10, now when i navigate to last page and delete the record number 91, it does not reload the grid automatically, when i use ReloadGrid explicitly it went to reload the whole data from controller which increases the network load.
  <img src="https://i.stack.imgur.com/PNtQt.png" alt="This is the Screen shot of last page">
  <img src="https://i.stack.imgur.com/Lzjlu.png" alt="Now I am deleting the last Record">
  <img src="https://i.stack.imgur.com/vMp1T.png" alt="It does not redirect to 1st page"></p>
  
  <p>2) In my grid there are 10 pages and when I enter the page number greater than the max page in text box it gives the blank grid, ideally it should dispaly some message.</p>
  
  <p><img src="https://i.stack.imgur.com/DLM2S.png" alt="Here I&#39;ve given page no = 50 though max page = 1"></p>
  
  <p>any solution?</p>
  
  <p><strong>ADDED CODE FOR BETTER UNDERSTANDING OF PROBLEM</strong></p>
  
  <pre><code>$(document).ready(function () {
          $('#jqgCars').jqGrid({
              //url from wich data should be requested
              url: '@Url.Action("CarsListing", "Car")?Carid=' + getID(),
              //event for inline edit
              onSelectRow: function (currentSelectedRow) {
                  if (currentSelectedRow &amp;&amp; currentSelectedRow != $.lastSelectedRow) {
                      //save changes in row 
                      $('#jqgCars').jqGrid('saveRow', $.lastSelectedRow, false);
                      $.lastSelectedRow = currentSelectedRow;
                  }
              },
              //type of data
              datatype: 'json',
              //url access method type
              mtype: 'POST',
              //columns names
              colNames: ['ID','Number','Name'],
              //columns model
              colModel: [
                              { name: 'ID', index: 'ID', align: 'left', editable: false },
                              { name: 'Number', index: 'Number', align: 'left', editable: true, formatter: "text", edittype: 'text', editrules: { required: true}, editoptions:{maxlength:"25"}},
                              { name: 'Name', index: 'Name', align: 'left', editable: true, formatter: "text", edittype: 'text', editrules: { required: false} , editoptions:{size:"35",maxlength:"255"}},
                            ],
              //pager for grid
              pager: $('#jqgpCars'),
              //number of rows per page
              rowNum: 2,
              //initial sorting column
              sortname: 'name',
              //initial sorting direction
              sortorder: 'asc',
              //display total records count
              viewrecords: true,
              //grid height
              height: '100%' 
          });
          $('#jqgCars').jqGrid('navGrid', '#jqgpCars', { add: true, del: true, edit: true, search: false });
          $('#jqgCars').jqGrid('hideCol', "ID");
          $('#jqgCars').setGridWidth(600 , true);
          var dialogPosition = $(this).offset();
      });
  </code></pre>
  
  <p><strong>UPDATE -- SOLUTION</strong></p>
  
  <p><strong>Solution to problem#1</strong></p>
  
  <pre><code>$.extend($.jgrid.del, {
              afterComplete: function () {
                  var p = $('#jqgCars')[0].p;
                  var newPage = p.page; // Gets the current page
                  if (p.reccount === 0 &amp;&amp; newPage &gt; p.lastpage &amp;&amp; newPage &gt; 1) {
                      // if after deleting there are no rows on the current page and lastpage != firstpage than
                      newPage--; // go to the previous page
                  }
                  // reload grid to make the row from the next page visable.
                  $(p.pager + " input.ui-pg-input").val(newPage); //Here setting the new page into textbox before loading in case of longer grid it would look nice
                  $('#jqgCars').trigger("reloadGrid", [{page: newPage}]); // reloading grid to previous page
              } 
          });
  </code></pre>
  
  <p><strong>Solution of problem#2</strong> is exact as posted by Oleg</p>
  
  <p><strong>This works fine with jqGrid v4.1.2</strong></p>