Data Grid state schema
What it does
Section titled “What it does”Describes a Data Grid’s view state for tools, such as an AI assistant that changes the view on request:
dataGridStateSchema(grid): a JSON Schema (draft 2020-12) of the statesetStateaccepts, with this grid’s column ids, filter kinds, groupable columns, and pivot aggregates.describeState(grid): a short English summary of the current view.applyState(grid, state): validates and applies a proposed state; returns{ ok: true }or{ ok: false, error }so the tool can correct its proposal.
import { DataGrid } from '@absoluteui/components/data-grid';import { applyState, dataGridStateSchema, describeState } from '@absoluteui/components/data-grid/schema';
interface Person { id: string; name: string; age: number;}
const host = document.createElement('div');host.style.setProperty('block-size', '200px');document.body.append(host);const grid = DataGrid.create<Person>(host, { label: 'People', rows: [{ id: '1', name: 'Ada', age: 36 }], rowId: (r) => r.id, columns: [ { id: 'name', header: 'Name', field: 'name' }, { id: 'age', header: 'Age', field: 'age', type: 'number' }, ],});console.log(dataGridStateSchema(grid), describeState(grid));const result = applyState(grid, { sort: [{ column: 'age', direction: 'descending' }] });if (!result.ok) console.log(result.error);Behavior
Section titled “Behavior”- Only view state: sort, columns, paging, filters, quick and advanced filters, grouping, and the pivot. No row data, no edits, no row ids: the schema and summary are safe to send to a service that should not see the data.
- Treat the tool’s proposal as untrusted input:
applyStatevalidates it likesetStateand changes nothing when it is invalid.
API reference
Section titled “API reference”Functions
Section titled “Functions”applyState
Apply a proposed view state; returns the validation message instead of throwing (for tool loops).
function applyState<Row>(grid: DataGrid<Row>, state: unknown): { readonly ok: true;} | { readonly ok: false; readonly error: string;};dataGridStateSchema
A JSON Schema of the view state setState accepts for this grid (draft 2020-12): sort, columns (order,
widths, pinning, visibility, collapsed groups, header names), paging, column filters by their kinds, the
quick filter, grouping and expansion, master/detail expansion, and the pivot. Column ids are enumerated;
the description lists each column’s header and type.
function dataGridStateSchema<Row>(grid: DataGrid<Row>): JsonSchema;describeState
A short English description of the current view (for a tool’s context, not for display).
function describeState<Row>(grid: DataGrid<Row>): string;JsonSchema
A JSON Schema object (plain JSON).
type JsonSchema = Readonly<Record<string, unknown>>;(c) 2026 Kasadara Technology Solutions Pvt Ltd. AbsoluteUI is free to use under the AbsoluteUI Free Use License; it is not open source.