Class: PersistentState

PersistentState

Save the state of column sorting, column positions and column sizes in local storage to preserve table state
between page reloads.

In order to enable data storage mechanism, Options#persistentState option must be set to true.

When persistentState is enabled it exposes 3 hooks:

  • Hooks#persistentStateSave - Saves value under given key in browser local storage.
  • Hooks#persistentStateLoad - Loads value, saved under given key, from browser local storage. The loaded
    value will be saved in saveTo.value.
  • Hooks#persistentStateReset - Clears the value saved under key. If no key is given, all values associated
    with table will be cleared.

Methods

destroy()

Destroys the plugin instance.

disablePlugin()

Disables the plugin functionality for this Handsontable instance.

enablePlugin()

Enables the plugin functionality for this Handsontable instance.

isEnabled(){Boolean}

Checks if the plugin is enabled in the handsontable settings. This method is executed in Hooks#beforeInit
hook and if it returns true than the PersistentState#enablePlugin method is called.

Returns: {Boolean}

loadValue(key, saveTo)

Loads the value from local storage.

Parameters:
Name Type Description
key String

Storage key.

saveTo Object

Saved value from local storage.

resetValue(key)

Resets the data or all data from local storage.

Parameters:
Name Type Description
key String

[optional] Storage key.

saveValue(key, value)

Saves the data to local storage.

Parameters:
Name Type Description
key String

Storage key.

value Mixed

Value to save.

updatePlugin()

Updates the plugin state. This method is executed when Core#updateSettings is invoked.