State Persistence
13 Jun 20231 minute to read
State persistence is to maintain the grid state in browser’s local storage even if browser refreshes or move to the next page. State persistence stores grid’s model object in local storage while defining the enablePersistence
as true.
IMPORTANT
The localStorage is not supported below IE9 then grid state persistence technique is fallback to cookie.
List of properties are not persisted by default
The following properties are not included while maintaining the grid state in local storage to keep localStorage compact.
- Query
- isEdit
- toolbarClick
- queryCellInfo
- mergeCellInfo
- currentViewData
- enableAltRow
- enableRTL
- contextClick
- contextOpen
- rowDataBound
- rowTemplate
- detailsDataBound
- detailsTemplate
- childGrid
- summaryRows
- toolbarSettings
- editSettings
- allowMultiSorting
- enableAutoSaveOnSelectionChange
- locale
- allowScrolling
- allowCellMerging
- allowTextWrap
- cssClass
- dataSource
- groupSettings.enableDropAreaAnimation
- enableRowHover
- showSummary
- allowGrouping
- enableHeaderHover
- allowKeyboardNavigation
- scrollSettings.frozenRows
- scrollSettings.frozenColumns
- enableTouch
- editSettings.rowPosition
- editSettings.showAddNewRow
- contextMenuSettings.enableContextMenu
IMPORTANT
The given excluded properties can be included in persist state using the
_ignoreOnPersist
in grid prototype.
Accessing currently stored state
The persisted state can be accessed through local storage using the corresponding key name. Key name is the combination of plugin name and control id.
var gridStateString = window.localStorage.ejGridGrid; // grid state as string
var gridStateObject = JSON.parse(window.localStorage.ejGridGrid);//grid state as object
IMPORTANT
In the above example, the “ejGrid” is plugin name and “Grid” is control id.