What is the general way to use State?

What is the general way to use State?

dbarondbaron Posts: 10Questions: 4Answers: 0

My DataTables will only show a small subset of the fields within each row's object. In order to view and/or edit them all I will have to navigate to a completely separate page, not simply open a popup with a half-dozen fields. The notion of using State seems enticing. Am I to understand the following:
a) Assuming that the StateSave option was set, that every time the user manipulates a DT, its 'state' is saved?
b) That is the user navigates to a separate web page, that State data lives on in local storage?
c) That is the user re-navigates back to the DT page, my js can somehow 'ask' if there is a State data available? If the answer to that is yes, then, I presume the DT object must be instantiated first (?), which usually involves loading it with data... How can I use the object to find out if there is State Data available without loading the data (as would normally occur on the 'first time in' to that page?
d) Assuming I can somehow determine that there is State data available, and that it is 'fresh enough', how to I tell the Dt object to 're-load that State data', versus 'load the usual js array of objects I created for you via ajax call to server'?
e) Assuming I can somehow tell the DT to re-load the previously saved State data, does the DT literaly 'fill up' with the 'displayed' rows from 'last time', meaning, filtered data would be hidden, and in the correct sort order, and... the biggie, if the user had previously scrolled [a fixed height, overflow-scrolling] the DT 'down' to edit a row, would that row be 'made visible', i.e., would the DT be scrolled down to the point where the user could 'see' the results of their edits on the 'details' page?

Thanks so much...

-David

This question has an accepted answers - jump to answer

Answers

  • jr42.gordonjr42.gordon Posts: 305Questions: 2Answers: 49
    Answer ✓

    Much of your questions can be answered here. Make sure and read the "Related" section.

    I think by default, it only stores the DT config. If you needed to store data, utilize stateSaveCallback and stateLoadCallback options.

  • dbarondbaron Posts: 10Questions: 4Answers: 0

    Thank you - I took your advice and played around a bit. As you probably would know, simply setting stateSave to true magically handles almost everything. It is very impressive. I also utilized the callbacks to save and re-load my 'vertical scroll position' (I do not use paging) so that the user can 'see' the item in the list they just 'editted' (on the separate page).

    Great tool!

    -David

This discussion has been closed.