title: Save state of custom filter on jQuery DataTable plugin
body: <p>I have custom jQuery datatable filter applied on my dynamic data which is coming from REST API result. the code is as below:</p>
  
  <pre><code>$('#jQmyCases').DataTable({ 
      //... All the required options are here ...
      // Fetch data from REST API
  });
  </code></pre>
  
  <p>Once data are loaded, I initialize the my custom filter with below snippet:</p>
  
  <pre><code>$('#jQmyCases thead').append('&lt;tr id="filters"&gt;&lt;th col="ItemColor"&gt;Item Color&lt;/th&gt;&lt;th&gt;..&lt;/th&gt;....&lt;/tr&gt;'); // Many filters r there but i have only added one
  </code></pre>
  
  <p>First I append the filter string in <code>thead</code> then I bind custom filter a dropdwon with the available options from the received data, see below snippet:</p>
  
  <pre><code>$("#filters th").each(function (i) {
      var colheader = $(this).attr('col');
      var select = $('&lt;select id="ddl' + colheader + '" style="width:80px;"&gt;&lt;option value=""&gt;Selecteer ' + $(this).attr('col') + '&lt;/option&gt;&lt;/select&gt;')
                      .appendTo($(this).empty())
                      .on('change', function () {
                          dataTableExample.column(i)
                         .search($(this).val())
                         .draw();
                      });
  
  
      dataTableExample.column(i).data().unique().sort().each(function (d, j, full) {
          try {
              if (full[j] != null) {
                  if (i == 3) { // Column Color
                      var itemColor = full[j];
                      select.append('&lt;option value="' + itemColor + '"&gt;' + itemColor + '&lt;/option&gt;');
                  }
              }
          }
          catch (err) {
              console.log(err);
          }
      });
  });
  </code></pre>
  
  <p>Now I have to save state of the datatable so that in the next reload of the page, it does save the values of dropdown and show the previous results.</p>
  
  <p>I have looked <a href="https://www.flynsarmy.com/2011/12/save-custom-filter-state-jquery-data-tables/" rel="nofollow noreferrer">here</a>, which has shown some logic what I want but it has the static option as a filter.</p>
  
  <p><strong>Question:</strong> How can I achieve <code>saveState</code> option with my custom filter on jQuery dataTable plugin? Does anyone have workaround fro this? </p>
  
  <p>Any help would be much appreciated.</p>