title: On which jQgrid event I can apply changes to jQgrid
body: <p>I want to load jQgrid data(i.e sorted column, sort order, page) from cookie so that jQgrid can take changes from cookie <strong>when  user again reopen the page</strong> the code should take changes from cokkie are as follows:</p>
  
  <pre><code>function loadGridFromCookie(name) 
      {
          var c = $.cookie(name /*+ window.location.pathname*/);
          if (c == null)
              return;
          gridInfo = $.parseJSON(c);
          var grid = $("#" + name);
          grid.jqGrid('setGridParam', { sortname: gridInfo.sortname });
          grid.jqGrid('setGridParam', { sortorder: gridInfo.sortorder });
          grid.jqGrid('setGridParam', { page: gridInfo.page });
          grid.trigger("reloadGrid");
      }
  </code></pre>
  
  <p>My entire code : </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function getData(jqGridParams) 
      {
          var params = new Object();
          params.pageIndex = jqGridParams.page;
          params.pageSize = jqGridParams.rows;
          params.sortIndex = jqGridParams.sidx;
          params.sortDirection = jqGridParams.sord;
          params._search = jqGridParams._search;
          if (jqGridParams.filters === undefined)
              params.filters = null;
          else
              params.filters = jqGridParams.filters;
  
          // AJAX call
          $.ajax({
              url: 'WSAjax.asmx/GetDataForGrid',
              type: "POST",
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              data: JSON.stringify(params),
              success: function (data, textStatus) 
              {
                  if (textStatus == "success") 
                  {
                      var grid = $("#ItemGrid")[0];
                      grid.addJSONData(data.d);
                  }
              },
              error: function (jqXHR, textStatus, errorThrown) 
              {
                  alert(textStatus, errorThrown);
              }
          });
      }
  
      function saveGridToCookie(name, grid)     // save data into cookie
      {
          var gridInfo = new Object();
          //name += window.location.pathname;
          gridInfo.sortname = grid.jqGrid('getGridParam', 'sortname');
          gridInfo.sortorder = grid.jqGrid('getGridParam', 'sortorder');
          gridInfo.page = grid.jqGrid('getGridParam', 'page');
          //$('#Hidden').val(JSON.stringify(gridInfo));
          //alert($('#Hidden').val());
          $.cookie(name, JSON.stringify(gridInfo), {expires: 3});
      }
  
      function loadGridFromCookie(name)  // load data from cookie
      {
          var c = $.cookie(name /*+ window.location.pathname*/);
          if (c == null)
              return;
          var gridInfo = $.parseJSON(c);
          var grid = $("#" + name);
          grid.jqGrid('setGridParam', { sortname: gridInfo.sortname });
          grid.jqGrid('setGridParam', { sortorder: gridInfo.sortorder });
          grid.jqGrid('setGridParam', { page: gridInfo.page });
          grid.trigger("reloadGrid");
      }
  
      // Jquery code
      $(document).ready(function () {
          var oItemGrid = $("#ItemGrid");
          oItemGrid.jqGrid({
              datatype: 
                  function (jqGridParams) {
                  getData(jqGridParams);
                  },
              colNames: ['Type', 'Name', 'Desc'],
              colModel: [
                  { name: 'Type', index: 'Type', width: 40 },
                  { name: 'Name', index: 'Name', width: 40 },
                  { name: 'Desc', index: 'Desc', width: 40, sortable: false}],
              autowidth: true,
              height: 'auto',
              rowNum: 10,
              rowList: [10, 20, 30, 40],
              viewrecords: true,
              gridview: true,
              autoencode: true,
              ignoreCase: true,
              caption: 'Remember Sorting and Filtering Functionality',
              pager: '#IGPager',
              loadComplete: function(data) 
              {
                  var cookieval = $.cookie("ItemGrid");
                  if (cookieval != null) 
                  {
                      alert("From loadComplete: " + cookieval);
                      loadGridFromCookie("ItemGrid");
                  }
              },
              gridComplete: function () {
                  var prvData = $.cookie("ItemGrid");
                  alert("stored Data from cookie : " + prvData);
                  loadGridFromCookie("ItemGrid", gridInfo);
                  saveGridToCookie("ItemGrid", $("#ItemGrid"));
                  var storeval = $.cookie("ItemGrid");
                  alert("From gridComplete: " + storeval);
              }
              //loadonce: true
          }).jqGrid('navGrid', '#IGPager', { edit: false, add: false, del: false }, {}, {}, {}, {}, {});
      });
  &lt;/script&gt;
  </code></pre>