Quantcast
Channel: DataTables 1.9 — DataTables forums
Viewing all articles
Browse latest Browse all 1816

Clear saved state by clearing local storage

$
0
0
Hi

My application uses tables with a whole bunch of columns. I'm using the fabulous ColVis plugin to hide and show the columns the user wants. Thanks to fnStateSave, I can very easily keep all filters and columns present after a page reload.

The problem is that if there's a filter present in one of the columns (I've got input boxes below each column) and that column is hidden, it's confusing for the user. The user sees a filtered table, but cannot see which column has been filtered.

My question is: I would like to implement a global table reset button, that clears the saved state of the current table only: filters, columns... the whole shabang. Ideally the button would be displayed in the same manner as the TableTools and ColVis buttons.

How would I go about implementing such a feature?

		"bStateSave": true,
		"fnStateSave": function (oSettings, oData) {
            localStorage.setItem( 'DataTables_'+window.location.pathname, JSON.stringify(oData) );
        },
        "fnStateLoad": function (oSettings) {
            return JSON.parse( localStorage.getItem('DataTables_'+window.location.pathname) );
        },		
		"fnStateLoadParams": function (oSettings, oData) {
			$(oData.aoSearchCols).each(function(index,value) {
				if(value.sSearch != '') {
					$("input.search_init[data-colno='" + index + "']").val(value.sSearch);
				}
			});
		}


Thanks in advance for your answer. And thank you for your great software! My client LOVES it!

Viewing all articles
Browse latest Browse all 1816

Trending Articles