Interface StateStorageIf

Where AutoRestoreOptionsIf stores the state of a table (AutoRestoreOptionsIf.storage). A synchronous key-value store with the method names of the Web Storage API – localStorage (default) and sessionStorage fit directly.

The table reads the state while it is built, so the storage must answer synchronously. To keep the state on a server, load it before you create the table and pass it as TableOptionsIf.initialState; save it in EventListenerIf.onStateChanged.

Example

const tableOptions: TableOptionsIf = {
...new TableOptions(),
autoRestoreOptions: {
...new AutoRestoreOptions<Order>(),
getStorageKeyFn: () => "orders",
storage: sessionStorage, // forget the layout when the tab is closed
autoRestoreColumnLayout: true
}
};

Example

// an own storage, e.g. a prefix for all keys
const prefixed: StateStorageIf = {
getItem: key => localStorage.getItem("my-app/" + key),
setItem: (key, value) => localStorage.setItem("my-app/" + key, value),
removeItem: key => localStorage.removeItem("my-app/" + key)
};

Since

1.1.92

Hierarchy

  • StateStorageIf

Methods