How can I modify the string that stateSave uses for setting and retrieving from local storage?

How can I modify the string that stateSave uses for setting and retrieving from local storage?

user0ne23user0ne23 Posts: 2Questions: 1Answers: 0

right now by default it seems to be using this command:

localStorage.setItem('DataTables_table_id_' + window.location.pathname, JSON.stringify(data));

I want to change the first parameter or the key to the data.

'DataTables_table_id_' + window.location.pathname

to something else.

Answers

  • allanallan Posts: 63,844Questions: 1Answers: 10,518 Site admin

    You can use the stateSaveCallback option (and its partner stateLoadCallback) to define your own state storage.

    Allan

  • user0ne23user0ne23 Posts: 2Questions: 1Answers: 0

    I only see an example with ajax in there using server storage.

    Do you have any examples with customizing the key for localStorage?

    I am fairly new not sure on how the syntax would work.

  • allanallan Posts: 63,844Questions: 1Answers: 10,518 Site admin

    You've already got the syntax from the post you gave above :smile:. Its just a case of storing it in localStorage with the key you want.

    Allan

This discussion has been closed.