Saved Views
Preview

Capture, restore, and persist durable DataGrid configuration.

Overview

Use useDataGridView when users need to save and restore a grid configuration. A view can include filters, column visibility, order and pinning, sorting, grouping, and pivoting when those features are enabled. Pivot preferences such as source-row visibility are included.

Transient state is excluded, including records, column sizing, selection, focus, editing, expansion, row pinning, and virtualization. The consumer owns view names, permissions, defaults, URLs, and storage.

Example

This example uses one filter definition for the control, codec, and table. Change the grid, save its current view, then restore it.

Use capture() to read the current view and encode() or stringify() to prepare it for storage or a URL. Use restore() for untrusted stored input; it validates the value, removes stale configuration, applies the result, and reports whether it was unchanged, reconciled, or replaced by a fallback.

Use reconcile() to inspect input without changing the table and apply() only for an already typed view. subscribe() observes durable view changes and returns its cleanup function; it does not persist them.

API Reference

useDataGridView

Prepare the columns and table options required for durable views, then pass both results to useDataGridTable.

OptionTypeDefaultDescription
columnsreadonly DataGridColumnDef<TData>[]-Stable source columns. Required.
codecDataGridViewCodec<TDefinition>-Codec for the view shape and optional Filters definition. Required.
initialViewDataGridViewState<TDefinition>Codec default or empty viewInitial view reconciled against the table.
filteringStrategy"client" | "server""client"Selects client or server filtering.
filtersDataGridViewFilterOptions<TData, TDefinition>-Optional field mappings, evaluators, faceting, and hierarchy settings.

createDataGridViewCodec

OptionTypeDefaultDescription
defaultViewDataGridViewState<TDefinition>-Supplies the default initial view and reconciliation fallback.
filterDefinitionTDefinition-Adds typed Cubitt Filters state to the view codec.

table.dataGridView

APISignature or typeDescription
capture() => DataGridViewState<TDefinition>Returns a detached snapshot of the current durable view.
reconcile(input, options?) => DataGridViewReconcileResult<TDefinition>Validates and repairs input against the current table without applying it.
apply(state: DataGridViewState<TDefinition>) => voidApplies an already typed view.
restore(input, options?) => DataGridViewRestoreResult<TDefinition>Reconciles untrusted input, applies the result, and returns diagnostics.
subscribe(listener) => () => voidObserves durable view changes and returns a cleanup function.
codecDataGridViewCodec<TDefinition>Codec installed for the table.

View types and codec

ExportTypeDescription
DataGridViewState<TDefinition>Readonly versioned objectJSON-safe durable view state.
DataGridViewCodec<TDefinition>Codec objectType returned by createDataGridViewCodec.
DataGridViewReconcileResult<TDefinition>Discriminated resultReports unchanged, reconciled, or fallback with any issues.
DataGridViewRestoreResult<TDefinition>DataGridViewReconcileResult<TDefinition>Result returned after restoring untrusted input.
DataGridViewReconcileIssue{ slice, code, id? }Identifies a stale, invalid, or unsupported view entry.
DataGridViewTransport<TDefinition>Saved-view API objectType of table.dataGridView.

Codec methods

APISignatureDescription
codec.encode(state) => JsonValueReturns detached canonical JSON for structured storage.
codec.stringify(state) => stringReturns canonical text for URL or string storage.
codec.parse(input) => DataGridViewCodecParseResult<TDefinition>Parses untrusted input without reading the table.
codec.equals(left, right) => booleanCompares two views by their canonical representation.

On this page