DataTables 1.13 render table state

DataTables 1.13 render table state

sesplersespler Posts: 12Questions: 6Answers: 0

Hi,
I have a table that is setup to store its state in a location in localstorage that I can control. I use some other JS to load/save states into that localstorage item and then the table can take the state from that when it is loading via stateLoadCallback().

I'm wondering if there is a way to tell the table to grab this state in the localstorage and render according to what is there.
In DataTables 2.x you can use state as a setter but that is not available in 1.13.
I thought that table.draw() might do that, but that will write to the state actually.
Reloading the pages works fine, but I'm just wondering if there is a way that can be avoided for UX sake.

Thanks

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 64,519Questions: 1Answers: 10,664 Site admin
    Answer ✓

    You'd need to write a function that calls the API methods that you want to restore from the state information.

    table.page.len( state.length );
    table.page( state.start / state.length );
    // etc...
    

    I'm sure there used to be one kicking around, but I can't seem to find it.

    Best option is to update to v2, since v1 is no longer supported :).

    Allan

Sign In or Register to comment.