partly saving datatables state
partly saving datatables state
Hello, I tried to use datables such way that states would be saved partly, for example one table would have full state saving (simply saveState usage), the other table would work without state saving (again saveState usage), but yet another table should have state saving only for page length, but not other state properties. I used stateSaveParams and stateSaveCallback to connect my own function which had cleared 'data' object leaving only 'pagelength' attribute set. It didn't work unfortunately. Is there a simple way to get effect of selective state properties storage?
Replies
The
stateSaveParams
callback is the way to customise what data gets saved. Justdelete
the parameters that you don't want from the state object.Allan
@allan: I tried to make in stateSaveParams callback:
data = JSON.parse(JSON.stringify(data, [ "length"]));
but it didn't work - all state properties were saved in browser Local Storage.
You need to modify the original object that is passed in. The code above just assigned your new object to the local
data
parameter - not to the original object. Thedelete
keyword is one way of doing that.Allan
@allan: I see - thanks a lot.