I am using an external multi-select filter on some grids and for my purposes after leaving the page and coming back, I know that the filter values I used still exist but how to get them to populate the select again. So this is what I did and it could be used for anything.
The localStorage addition really helped a lot, thanks!
Below you will see the fnStateLoad and I added in the dataFN and other variable below it. if you reload and it is null it does nothing. I used it to find the column, this being 2, and grab the data to set the select box in a later function in the fnDrawCallback. I can elaborate more but basically if you are using localStorage, this allows you to parse the object and put back items that are not a part of the datatables object.
I can show all the code I did but this is the core of it. Hope it helps.
Enjoy.
The localStorage addition really helped a lot, thanks!
Below you will see the fnStateLoad and I added in the dataFN and other variable below it. if you reload and it is null it does nothing. I used it to find the column, this being 2, and grab the data to set the select box in a later function in the fnDrawCallback. I can elaborate more but basically if you are using localStorage, this allows you to parse the object and put back items that are not a part of the datatables object.
"bStateSave": true, "fnStateSave": function (oSettings, oData) { localStorage.setItem( 'DataTables_'+window.location.pathname, JSON.stringify(oData) ); }, "fnStateLoad": function (oSettings) { //look for the saved info for the Filter boxes. //if find match, then save it. dataFN = JSON.parse( localStorage.getItem('DataTables_'+window.location.pathname)); if (dataFN != null) { yourvariablename_sSearch = dataFN.aoSearchCols[2].sSearch; } return JSON.parse( localStorage.getItem('DataTables_'+window.location.pathname) ); },
I can show all the code I did but this is the core of it. Hope it helps.
Enjoy.