State Saving Challenge
State Saving Challenge
I am using the same Data Table with three different configurations on three different pages with different URLs (The following links aren't working - only to explain in which way the URLs deviate from each other.)
https://www.mySite.eu/?page=ctrMgmtServerSide
https://www.mySite.eu/?page=ctrMgmtClientSide
https://www.mySite.eu/?page=ctrMgmtInboxExp
I noticed that layout changes (e.g. column visibility) are effective for all of my three different pages regardless on what page I make them.
How can I make sure that state saving will only be effective for the page I make the change on, not for the other two pages using the same Data Table?
Replies
I found this here: https://datatables.net/reference/option/stateSave
"To be able to uniquely identify each table's state data, information is stored using a combination of the table's DOM id and the current page's pathname. If the table's id changes, or the page URL changes, the state information will be lost."
I am using different URLs for my three pages that have the same table so why are changes on one page effective for all of them?
In the meantime I found a work around. On two of the three pages I need independent state saving. On the third page state saving is not allowed because it causes too much trouble.
This code saves the states of the two pages independently of each other. For the third page it does nothing which is ok because state saving is disabled for that page anyway.
Interesting - the query string parameter is not included in the state saving path, so that should make no difference.
Are you able to give me a link to your page (I'm assuming mySite.eu is a placeholder)?
Allan
Hi Allan, if the query string isn't part of the path, the behavior is clear for me: Then all three pages have the same path and the Data Tables on the three pages have the same DOM id. No surprise that they share the same state.
This is my solution right now with another work around.Using state saving causes problems with column search which I use in one of the three pages. All the stuff on "initComplete" is for that page. If the user excluded columns from view and the data table was reloaded column search didn't work any longer. Somehting in the sequence of the columns got lost I guess. But I also noticed: Removing columns from view and then doing column search in the remaining columns did not cause any problems.
I just emulated the manual process:
- save the loaded state regarding column visibility
- make all columns visible
- do all the column search stuff while columns are visible
- restore the loaded state from the saved version
Of course the user doesn't notice anything of making columns visible and then invisible again. But now column search works also with state saving.