Skip to content

@jsvision/datagrid / GridVariant

Interface: GridVariant

Defined in: datagrid/src/variant.ts:67

A named, serializable snapshot of a grid's column layout — the object saveVariant returns and applyVariant consumes. Array order in columns is the full column order (hidden interleaved). It is plain JSON (no functions), so a caller can persist it however it likes.

Example

ts
import { signal } from '@jsvision/ui';
import { column, fromRows, EditableDataGrid, type GridVariant } from '@jsvision/datagrid';

interface Row { id: number; name: string }
const rows = signal<Row[]>([{ id: 1, name: 'Ada' }]);
const columns = [column({ id: 'name', title: 'Name', value: (r: Row) => r.name })];
const grid = new EditableDataGrid<Row>({ columns, source: fromRows(rows, { rowKey: (r) => r.id }) });

const mine: GridVariant = grid.saveVariant('mine'); // persist mine somewhere…
grid.applyVariant(mine);                            // …and restore it later

Properties

columns

readonly columns: GridVariantColumn[]

Defined in: datagrid/src/variant.ts:71

The full column order (hidden interleaved), each with its visibility and optional width.


filter

readonly filter: object[]

Defined in: datagrid/src/variant.ts:77

The per-column filters, as { columnId, filter } pairs.

columnId

columnId: string

filter

filter: ColumnFilter


freeze

readonly freeze: object

Defined in: datagrid/src/variant.ts:73

The frozen partition: column ids pinned to the left and right panels.

left

left: string[]

right: string[]


name

readonly name: string

Defined in: datagrid/src/variant.ts:69

A caller-facing label for the variant.


sort

readonly sort: SortKey[]

Defined in: datagrid/src/variant.ts:75

The sort model (ordered keys; the first is primary).