# DataGridState (@salmonui/data-grid/engine)

> The DataGridState type of @salmonui/data-grid/engine: Versioned, JSON-serializable grid state. Columns are referenced by field (falling back to the column id when a column has no field). Every part is optional on input: a partial state restores what it has.

Canonical: https://salmonui.dev/docs/reference/data-grid/engine/DataGridState

```ts
import type { DataGridState } from '@salmonui/data-grid/engine';
```

Also exported from `@salmonui/data-grid`, `@salmonui/data-grid/engine/persistence`.

Entry index: https://salmonui.dev/docs/reference/data-grid/engine (Markdown with every symbol of the entry: https://salmonui.dev/docs/reference/data-grid/engine.md).

## Reference

Kind: type

```ts
type DataGridState = {
    readonly version: 1;
    readonly columns?: readonly PersistedColumn[];
    readonly pinning?: PersistedPinning;
    readonly sorting?: readonly {
        readonly field: string;
        readonly direction: 'asc' | 'desc';
    }[];
    readonly filters?: readonly PersistedFilter[];
    readonly grouping?: readonly string[];
    readonly paging?: {
        readonly page: number;
        readonly pageSize: number;
    };
    readonly search?: {
        readonly text: string;
        readonly fields: readonly string[];
        readonly operator: SearchOperator;
        readonly matchCase: boolean;
        readonly ignoreAccents: boolean;
    } | null;
    readonly pinnedRows?: {
        readonly rowIds: readonly RowId[];
        readonly unpinnedRowIds: readonly RowId[];
    };
    readonly tree?: {
        readonly expandedRows: Readonly<Record<RowId, boolean>>;
        readonly defaultExpanded: boolean | number;
    };
    readonly selection?: SerializedSelection;
    readonly scroll?: {
        readonly top: number;
        readonly left: number;
    };
};
```

Versioned, JSON-serializable grid state. Columns are referenced by `field`
(falling back to the column id when a column has no field). Every part is
optional on input: a partial state restores what it has.

Members (12):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `version` | `readonly version: 1;` |  |  |
| `columns` | `readonly columns?: readonly PersistedColumn[];` | optional |  |
| `pinning` | `readonly pinning?: PersistedPinning;` | optional |  |
| `sorting` | `readonly sorting?: readonly {     readonly field: string;     readonly direction: 'asc' \| 'desc'; }[];` | optional |  |
| `filters` | `readonly filters?: readonly PersistedFilter[];` | optional |  |
| `grouping` | `readonly grouping?: readonly string[];` | optional |  |
| `paging` | `readonly paging?: {     readonly page: number;     readonly pageSize: number; };` | optional |  |
| `search` | `readonly search?: {     readonly text: string;     readonly fields: readonly string[];     readonly operator: SearchOperator;     readonly matchCase: boolean;     readonly ignoreAccents: boolean; } \| null;` | optional |  |
| `pinnedRows` | `readonly pinnedRows?: {     readonly rowIds: readonly RowId[];     readonly unpinnedRowIds: readonly RowId[]; };` | optional | Pinned rows (`rowPinning` module): rows pinned explicitly and rows unpinned although `isRowPinned` matches them. Rows the predicate pins are not listed (the predicate pins them again). |
| `tree` | `readonly tree?: {     readonly expandedRows: Readonly<Record<RowId, boolean>>;     readonly defaultExpanded: boolean \| number; };` | optional | Tree mode expansion (`tree` module): per-row overrides over the default (`true`, `false`, or a depth n: rows of depth < n expanded). Present only through the tree entry's state wrappers. |
| `selection` | `readonly selection?: SerializedSelection;` | optional |  |
| `scroll` | `readonly scroll?: {     readonly top: number;     readonly left: number; };` | optional | Scroll offset in px, applied by the renderer. |
