title: How do I retain filters in JqGrid whilst still getting remote data?
body: <p>I'm using <a href="http://www.ok-soft-gmbh.com/jqGrid/UsageFormetterSelect2.htm" rel="nofollow">this demo</a> to display text and dropdown list filters in the columns of a JqGrid. The grid has a remote data source and with each sort, filter, or page view etc, it grabs the data from the remote source.</p>
  
  <p>The problem I am having is that when the new data arrives, the grid is refreshed, and the filters revert to default. I've looked at a few examples by Dr Oleg but I can't get it to work with remote data and persistence. Any setting of <code>datatype</code> to <code>"local"</code> or <code>loadonce</code> to <code>true</code> breaks the remote datasource.</p>
  
  <p>Does anyone have any ideas of how to get this to work?</p>
  
  <p>I've tried the following, but as I said, this stops the JqGrid from making API requests:</p>
  
  <pre><code>loadComplete: function () {
      var $this = $(this);
      var postfilt = $this.jqGrid('getGridParam', 'postData').filters;
      var postsord = $this.jqGrid('getGridParam', 'postData').sord;
      var postsort = $this.jqGrid('getGridParam', 'postData').sidx;
      var postpage = $this.jqGrid('getGridParam', 'postData').page;
  
      console.log(postfilt);
      console.log(postsord);
      console.log(postsort);
      console.log(postsort);*/
  
      if ($this.jqGrid("getGridParam", "datatype") === "json") {
          setTimeout(function () {
              $this.jqGrid("setGridParam", {
                  datatype: "local",
                  postData: { filters: postfilt, sord: postsord, sidx: postsort },
                  search: true
              });
              $this.trigger("reloadGrid", [{ page: postpage}]);
          }, 25);
      }
  }
  </code></pre>
  
  <p>I think the issue has something to do with the <code>select2</code> dropdown menus. Here you can see it destroys the filter menu and recreates it. </p>
  
  <pre><code>var options = colModelOptions, p, needRecreateSearchingToolbar = false;
  if (options != null) {
      for (p in options) {
          if (options.hasOwnProperty(p)) {
              if (options[p].edittype === "select") {
                  options[p].editoptions.dataInit = initSelect2;
              }
              if (options[p].stype === "select") {
                  options[p].searchoptions.dataInit = initSelect2;
              }
              $grid.jqGrid("setColProp", p, options[p]);
              if (this.ftoolbar) { // filter toolbar exist
                  needRecreateSearchingToolbar = true;
              }
          }
      }
      if (needRecreateSearchingToolbar) {
          $grid.jqGrid("destroyFilterToolbar");
          $grid.jqGrid("filterToolbar", filterToolbarOptions);
      }
  }
  </code></pre>
  
  <p>If there was a way this could be done just once per JqGrid load rather than per every request, then that may be a step in the right direction.</p>