GridState
NextGrid exposes a JSON-serializable state snapshot (GridState, currently version 5) via getState() and restores full snapshots or partial patches via applyState(patch) and initialState.
GridState (Version 5)
Section titled “GridState (Version 5)”export interface GridState { readonly version: 5; readonly sort: SortModel; readonly filters: FilterModel; readonly quickFilter: string; readonly pagination: Readonly<PaginationState>; readonly columns: Readonly<ColumnState>; readonly hierarchy: Readonly<HierarchyState>; readonly selection: Readonly<SelectionState | SelectionStateV3>; readonly pivot: Readonly<PivotState>; readonly details: Readonly<DetailState>; readonly pinnedTotals: false | Readonly<PinnedTotalsOptions>; readonly focus: Readonly<GridStateFocus>; readonly dormantColumns: readonly Readonly<PivotDormantColumnState>[]; readonly suspended: Readonly<SuspendedGridViewState> | null;}
export interface CurrentGridStatePatch extends Partial<Omit<GridState, 'version'>> { readonly version: 5;}Sub-Structures
Section titled “Sub-Structures”ColumnState (version: 1)
Section titled “ColumnState (version: 1)”export interface ColumnStateItem { readonly colId: string; readonly width: number; readonly isVisible: boolean; readonly pinned: ColumnPin; readonly flex: number | null;}
export interface ColumnState { readonly version: 1; readonly columns: readonly Readonly<ColumnStateItem>[];}SelectionState (v1, v2, v3)
Section titled “SelectionState (v1, v2, v3)”SelectionStateV1(version: 1): Legacy flat row IDs and cell key ranges (accepted byapplyStateforGridStateV3).SelectionState/SelectionStateV2(version: 2): Current non-pivot selection storingrowIds,ranges(CellRangeState), and row cohorts (ids,sourceIntervals, orhierarchy).SelectionStateV3(version: 3): StoresPivotCellRangeStatewhen client or server pivot mode is active.
HierarchyState & PivotState
Section titled “HierarchyState & PivotState”HierarchyState: Either{ mode: 'flat' }or{ mode: 'group' | 'tree', columns, valueColumns, aggregationScope, groupTotals, grandTotal, expansion: { defaultExpandedDepth, overrides } }.PivotState: Stores active pivot configuration, row/column dimensions, measures, totals, and expanded pivot group keys; inactive source-view columns/selection/sort/focus are preserved insuspended(SuspendedGridViewState) anddormantColumnswhile pivot is enabled.
Legacy Versions (v1–v4) & GridStatePatch
Section titled “Legacy Versions (v1–v4) & GridStatePatch”GridStatePatch accepts version: 5 (CurrentGridStatePatch) as well as legacy patches from earlier versions:
version: 1(LegacyGridStatePatch):sort,filters,quickFilter,paginationversion: 2(GridStateV2Patch): v1 +columnsversion: 3(GridStateV3Patch): v2 +selection(SelectionStateV1)version: 4(GridStateV4Patch): v2 +hierarchy+selection(SelectionState)
Omitted fields in a patch keep their current runtime values. Candidate states are validated atomically before publication so invalid patches never leave half-applied state.
What Is Not Serialized
Section titled “What Is Not Serialized”GridState never contains row payloads (rowData), mounted child grids, DOM nodes, remote block caches, measured row-height caches, supplied pinnedRows, cellSpans, or runtime callbacks (valueGetter, formatter, aggregateFunctions, detail.renderer). Reinstall matching callbacks and columnDefs before calling applyState.