State Persistence

25 Apr 20231 minute to read

State Persistence is to maintain the grid state in browser’s local storage even if browser refresh or move to next page. State persistence stores Grid’s model object in local storage while defining enablePersistence as true.

IMPORTANT

local storage 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 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 _ignoreOnPersist in grid prototype.

Accessing currently stored state

Persisted state can be accessed through local storage using corresponding key name. Key name is the combination of plugin name and control id.

  • JAVASCRIPT
  • 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, “ejGrid” is plugin name and “Grid” is control id.