Bobby
Bobby

Reputation: 113

DataTables Cookies With Custom Search

I added a few custom filters to Datatable and they work fine. The problem I have is when I go back to view the table I lose my custom filter (which makes sense).

When I do a

aoData.push( {  "name": "SomeVar", "value": "SomeVarInfo"} );

does DataTable save this extra information in the cookie? If not how do I add it to the cookie and how do I access it on the page load?

Datatables version 1.9.1

Thanks

Upvotes: 0

Views: 1754

Answers (2)

LenP
LenP

Reputation: 1

Using Datatables 1.9, I find that on iPad the localStorage workaround causes DataTables filter to break. The DT filter no longer selects the proper matching rows. When reverting to the default cookie method of saving DataTable state, the filter works ok again.

Upvotes: 0

Bobby
Bobby

Reputation: 113

I found that this worked for me. Its local storage though not cookies but works great

"fnStateSave": function (oSettings, oData) {
localStorage.setItem( 'DataTables', JSON.stringify(oData) );
},
"fnStateLoad": function (oSettings) {
return JSON.parse( localStorage.getItem('DataTables') );
}

Upvotes: 1

Related Questions