Interface AutoRestoreOptionsIf<T>

What a table remembers between page loads, and where. Everything is off by default (AutoRestoreOptions); nothing is stored without getStorageKeyFn (the table warns once if a flag is set without it).

The state is stored as one JSON value under <key>tableState in storage (default localStorage) – the same format as TableApi.getState. Columns are stored by property and rows by getRowId, so a moved column or new data never hits the wrong column or row. The stored state holds no cell values, but row ids can be personal data (e.g. an e-mail address as id) – prefer technical ids. The tree, checked rows, the selection and the first visible row need row ids; tree, checked and selected rows are computed only when their flag is set.

Flag Remembers since
autoRestoreSortingState sorted columns
autoRestoreScrollPosition scroll position
autoRestoreCollapsedExpandedState expanded tree nodes
autoRestoreColumnLayout width, order, visibility of the columns 1.1.92
autoRestoreHeaderGroupState collapsed header groups 1.1.92
autoRestoreCheckedState checked rows 1.1.92 (declared before, without effect)
autoRestoreSelectedState selection 1.1.92 (declared before, without effect)
autoRestoreCustomState your data (TableApi.setCustomState) 1.1.92
autoRestoreDetailState expanded detail rows (master/detail) 1.1.97

Before 1.1.92 sorting, scroll position and tree were stored under three keys (<key>sortingState, <key>scrollState, <key>collapsedExpandedState); they are read once and removed with the next save.

Example

const tableOptions: TableOptionsIf = {
...new TableOptions(),
autoRestoreOptions: {
...new AutoRestoreOptions<Order>(),
getStorageKeyFn: () => "orders",
getRowId: (order: Order) => order.id,
autoRestoreColumnLayout: true,
autoRestoreSortingState: true,
autoRestoreCheckedState: true
}
};

Typeparam

T - The type of the rows.

See

Training: Remember the state

Type Parameters

  • T

Hierarchy

  • AutoRestoreOptionsIf

Implemented by

Properties

autoRestoreCheckedState?: boolean

Remember the checked rows (by getRowId). Since 1.1.92 (before: declared without effect).

autoRestoreCollapsedExpandedState?: boolean

Remember expanded and collapsed nodes of a tree table (by getRowId).

autoRestoreColumnLayout?: boolean

Remember width, order and visibility of the columns (by property). Widths are stored only for columns that were resized, so % and weight columns stay responsive.

Since

1.1.92

autoRestoreCustomState?: boolean

Remember the data set with TableApi.setCustomState (e.g. a filter text).

Since

1.1.92

autoRestoreDetailState?: boolean

Remember the expanded detail rows of master/detail (TableOptionsIf.masterDetail, by getRowId).

Since

1.1.97

autoRestoreHeaderGroupState?: boolean

Remember collapsed and expanded header groups (CellGroupIf.toggle).

Since

1.1.92

autoRestoreScrollPosition?: boolean

Remember the scroll position (and the id of the first visible row).

autoRestoreSelectedState?: boolean

Remember the selection: rows by getRowId, columns by property. Restored in the current row order. Since 1.1.92 (before: declared without effect).

autoRestoreSortingState: boolean

Remember the sorted columns (by property).

getRowId?: GetRowIdFn<T>

A unique, stable id per row (tree: per node). With the default of AutoRestoreOptions the table uses the property id, then uuid; rows without them are not stored (since 1.1.92 – the JSON of the row would write personal data into the storage; the table warns once).

getStorageKeyFn?: GetStorageKeyFn

The storage key of this table, e.g. () => "orders". Without it nothing is stored.

isSame?: IsSameFn<T>

Deprecated

since 1.1.92 – never used; rows are compared by getRowId.

storage?: StateStorageIf

Where the state is stored. Default: localStorage; sessionStorage or an own StateStorageIf also work.

Since

1.1.92