partly saving datatables state

partly saving datatables state

chilekchilek Posts: 5Questions: 0Answers: 0
edited April 2017 in Free community support

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

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    The stateSaveParams callback is the way to customise what data gets saved. Just delete the parameters that you don't want from the state object.

    Allan

  • chilekchilek Posts: 5Questions: 0Answers: 0
    edited April 2017

    @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.

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    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. The delete keyword is one way of doing that.

    Allan

  • chilekchilek Posts: 5Questions: 0Answers: 0

    @allan: I see - thanks a lot.

This discussion has been closed.