View as Markdown

API reference: @salmonui/data-grid

DataGridColumnInfointerface

import type { DataGridColumnInfo } from '@salmonui/data-grid';
interface DataGridColumnInfo<Row = unknown> {
    readonly id: string;
    readonly field: string | null;
    readonly header: string;
    readonly type: ColumnType;
    readonly format: string | FormatOptions | undefined;
    readonly align: 'start' | 'center' | 'end' | 'justify' | undefined;
    readonly headerAlign: 'start' | 'center' | 'end' | undefined;
    readonly width: ColumnWidth;
    readonly minWidth: number;
    readonly maxWidth: number;
    readonly pinned: 'start' | 'end' | 'center' | null;
    readonly hidden: boolean;
    readonly sortable: boolean;
    readonly filterable: boolean;
    readonly searchable: boolean;
    readonly groupable: boolean;
    readonly editable: boolean;
    readonly resizable: boolean;
    readonly reorderable: boolean;
    readonly hideable: boolean;
    readonly primaryKey: boolean;
    readonly lockPosition: boolean;
    readonly displayAsCheckbox: boolean;
    readonly leaf: boolean;
    readonly depth: number;
    readonly path: readonly string[];
    readonly children: readonly string[];
    readonly definition: Readonly<Record<string, unknown>>;
    getValue(row: Row): unknown;
    formatValue(value: unknown, row: Row): string;
}

Read-only public view of a compiled column, as render props and events receive it. Field names follow the name table; flags carry their resolved defaults. Values are the definition's (runtime visibility, width, order, and pin state are in api.getState() and the column events).

DataGridColumnInfo members (30)
NameSignatureDescription
idreadonly id: string;

The column key: id, else field, else a generated id. Payloads call it field.

fieldreadonly field: string | null;

The data field (dot path), or null for columns without one.

headerreadonly header: string;
typereadonly type: ColumnType;
formatreadonly format: string | FormatOptions | undefined;
alignreadonly align: 'start' | 'center' | 'end' | 'justify' | undefined;
headerAlignreadonly headerAlign: 'start' | 'center' | 'end' | undefined;
widthreadonly width: ColumnWidth;
minWidthreadonly minWidth: number;
maxWidthreadonly maxWidth: number;

Infinity when unbounded.

pinnedreadonly pinned: 'start' | 'end' | 'center' | null;

Definition pin side.

hiddenreadonly hidden: boolean;

Definition visibility.

sortablereadonly sortable: boolean;
filterablereadonly filterable: boolean;
searchablereadonly searchable: boolean;
groupablereadonly groupable: boolean;
editablereadonly editable: boolean;
resizablereadonly resizable: boolean;
reorderablereadonly reorderable: boolean;
hideablereadonly hideable: boolean;

Listed in the column chooser.

primaryKeyreadonly primaryKey: boolean;
lockPositionreadonly lockPosition: boolean;
displayAsCheckboxreadonly displayAsCheckbox: boolean;
leafreadonly leaf: boolean;

False for stacked header groups.

depthreadonly depth: number;

Header depth (0 for top level).

pathreadonly path: readonly string[];

Stacked header group ids, root first, ending with this column.

childrenreadonly children: readonly string[];

Child column ids of a stacked header group.

definitionreadonly definition: Readonly<Record<string, unknown>>;

The column definition as given (columns entry or <DataGridColumn> props).

getValuegetValue(row: Row): unknown;

The column value of a row (valueGetter, else field).

formatValueformatValue(value: unknown, row: Row): string;

The display text of a value (valueFormatter, else format).