Browser back button doesnot save pagination history
Browser back button doesnot save pagination history
rishabhjkl
Posts: 4Questions: 1Answers: 0
Scenario : Main Page has a link to table
Path followed->
- At main page click on table link. Table gets opened.
- At bottom of the table, click through several pages.
- Click the browser's Back button.
- Gone to the main page.
Intended -> Clicking Back Button should go to last seen page.
For example - User click on page 4 then page 8 then page 7 , here after clicking back button it should go to page 8
This question has accepted answers - jump to:
This discussion has been closed.
Answers
There isn't currently a plug-in for DataTables that does that. Personally I generally considering that to be "breaking the back button" since you might sort, filter and page the table a number of times and then want to go back a page, but find you've added a whole bunch of stuff to the browser history.
That said, you could use
draw
to add information to the history stack and then use the API when the back button is pressed to reload the state for that point.Allan
Can we currently store a particular state of DataTables in local storage of browser (HTML5) every time draw event is called?
Sure - use
state()
in andraw
handler.Allan
Thanks, one more thing
how can we load saved state() ?
Currently there isn't actually a public API method to do that. There is one for the v2 branch which you might be able to back port, but the way I would normally recommend at the moment is to read the state saved object and then use the methods such as
page()
andsearch()
to set the state of the table.Allan
Draw event is fired once the table has completed a new draw but to save history we will need previous state info. How can we deal with this?