JQuery Datatables Hints and Tips
Save state (add to options)
stateSave: true
Add saved search keyword
// Restore state of global search var state = ExtendedTable.state.loaded(); if ( state ) { console.log("state", state); $("#SearchBox").val(state.search.search); };
Update clear button with active state
if(($('#SearchBox').length && $('#SearchBox').val().length)) { $("#clearFilter").addClass("active"); } else { $("#clearFilter").removeClass("active"); };
Update filter dropdowns inside initComplete
initComplete: function () { var state = ExtendedTable.state.loaded(); if ( state ) { var dateString = state.columns[2].search.search; //remove first and last characters var dateResult = dateString.slice(1, -1); $("#selectFilter1").val(dateResult).change(); }