Using StateSave but clearing it from main menu items

Using StateSave but clearing it from main menu items

tjyoungtjyoung Posts: 24Questions: 2Answers: 0
edited January 2020 in Free community support

Hi,
I have the odd datatable throughout my site. I'm using stateSave to maintain pagination etc. when the user drills down on a certain item and then returns using a javascript 'back' button. This all works great. I had to use stateSave because on mobile etc. if device is getting low memory and you use the javascript back button, the table will reload the data. So stateSave solved this dilemma.

Problem is, I'm wanting to clear any stateSave if the user clicks on any main menu buttons.

for example:
I'm on my 'inventory page' where there is a datatable. Each row has a clickable item so the user can drill down to get more info (for example a detail page of the item in the row). There is a javascript 'back()' button in case they wish to return to the datatable listing... and keeps their pagination etc. using stateSave.

but: if they click on any of the main menu items in the navigation of the site, I need to clear any/all stateSaves

Can I call a function to clear ALL datatables stateSaves so if they navigate back to any datatable on the site, the saved states are all gone?

Sorry its a long winded explanation, just wanted to be sure you knew exactly what I was meaning.

Thanks in advance for any help.

ps: the reason I'm looking to clear ALL the tables is I'm thinking the user will navigate away to other site pages and if they return to a table they have previously used, they will have forgotten / not realize its being filtered, sorted on some page other then page 1

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    The reference page for stateSave should help - it explains where the data is saved in the browser. You can delete those objects using standard localStorage or sessionStorage methods.

    Colin

This discussion has been closed.