Browser back button doesnot save pagination history

Browser back button doesnot save pagination history

rishabhjklrishabhjkl Posts: 4Questions: 1Answers: 0

Scenario : Main Page has a link to table

Path followed->

  1. At main page click on table link. Table gets opened.
  2. At bottom of the table, click through several pages.
  3. Click the browser's Back button.
  4. 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:

Answers

  • allanallan Posts: 63,461Questions: 1Answers: 10,466 Site admin
    Answer ✓

    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

  • rishabhjklrishabhjkl Posts: 4Questions: 1Answers: 0

    Can we currently store a particular state of DataTables in local storage of browser (HTML5) every time draw event is called?

  • allanallan Posts: 63,461Questions: 1Answers: 10,466 Site admin
    Answer ✓

    Sure - use state() in an draw handler.

    Allan

  • rishabhjklrishabhjkl Posts: 4Questions: 1Answers: 0

    Thanks, one more thing
    how can we load saved state() ?

  • allanallan Posts: 63,461Questions: 1Answers: 10,466 Site admin

    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() and search() to set the state of the table.

    Allan

  • rishabhjklrishabhjkl Posts: 4Questions: 1Answers: 0
    edited October 2018

    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?

This discussion has been closed.