How can I detect if stateSave is applying a changed state?

How can I detect if stateSave is applying a changed state?

stdticstdtic Posts: 1Questions: 1Answers: 0

Hi,

I have an HTML table complete with all the data I want to display. I am initialising it as a DataTable and setting some default options, such as "pageLength: 10", "searching: true", "ordering: true", "paging: true", etc.

I am also using the "saveState: true" option to automatically save/apply the state between page loads.

I would like to know if the table has a changed state (for example, if the user has changed the page length to 5), so I can display a message to the user notifying them the state has changed and allowing them to clear the state.

However, I cannot seem to find anything that tells me that the loaded state is different to the default. I can detect that a state has been applied using the "stateLoadParams" or "stateLoaded" events, but it just provides details on the loaded state.

Do I need to compare every detail of the loadedState to the original, default state manually? Or am I missing an easier way to do this?

Many thanks in advance

Answers

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

    The easiest way would be to listen stateSaveParams, as that will be triggered whenever the state is changed,

    Colin

Sign In or Register to comment.