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

> The ColumnDef interface of @salmonui/data-grid/engine.

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

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

Also exported from `@salmonui/data-grid`.

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: interface

```ts
interface ColumnDef<Row> {
    readonly id?: string;
    readonly field?: string;
    readonly valueGetter?: (row: Row) => unknown;
    readonly valueSetter?: (row: Row, value: unknown) => Row;
    readonly type?: ColumnType;
    readonly format?: string | FormatOptions;
    readonly header?: string;
    readonly headerValueGetter?: (column: CompiledColumn<Row>) => string;
    readonly align?: 'start' | 'center' | 'end' | 'justify';
    readonly headerAlign?: 'start' | 'center' | 'end';
    readonly width?: ColumnWidth;
    readonly minWidth?: number;
    readonly maxWidth?: number;
    readonly hidden?: boolean;
    readonly pinned?: 'start' | 'end' | 'center';
    readonly lockPosition?: boolean;
    readonly sortable?: boolean;
    readonly filterable?: boolean;
    readonly searchable?: boolean;
    readonly groupable?: boolean;
    readonly groupByFormat?: boolean;
    readonly groupKey?: (row: Row) => unknown;
    readonly editable?: boolean;
    readonly resizable?: boolean;
    readonly reorderable?: boolean;
    readonly primaryKey?: boolean;
    readonly identity?: boolean;
    readonly defaultValue?: unknown;
    readonly editor?: string;
    readonly editorProps?: {
        readonly [key: string]: unknown;
    };
    readonly validation?: ColumnValidation<Row, ValidatorContext<Row, CompiledColumn<Row>>>;
    readonly displayAsCheckbox?: boolean;
    readonly hideable?: boolean;
    readonly valueParser?: (input: unknown, ctx: ValueContext<Row>) => unknown;
    readonly valueFormatter?: (value: unknown, ctx: ValueContext<Row>) => string;
    readonly clipboardFormatter?: (value: unknown, ctx: ValueContext<Row>) => string;
    readonly sortComparator?: (a: unknown, b: unknown, rowA: Row, rowB: Row) => number;
    readonly filterComparator?: (value: unknown, filterValue: Json, operator: FilterOperator) => boolean;
    readonly lookup?: ColumnLookup;
    readonly columns?: readonly ColumnDef<Row>[];
    readonly meta?: Json;
}
```

Members (41):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `id` | `readonly id?: string;` | optional | columnId precedence: `id` > `field` > generated (development warning). |
| `field` | `readonly field?: string;` | optional | Dot paths are allowed: `customer.name`. |
| `valueGetter` | `readonly valueGetter?: (row: Row) => unknown;` | optional |  |
| `valueSetter` | `readonly valueSetter?: (row: Row, value: unknown) => Row;` | optional |  |
| `type` | `readonly type?: ColumnType;` | optional | Inferred from the first non-null value when absent. `selection` is the row selection checkbox column; `rowNumber` the row number column. |
| `format` | `readonly format?: string \| FormatOptions;` | optional |  |
| `header` | `readonly header?: string;` | optional |  |
| `headerValueGetter` | `readonly headerValueGetter?: (column: CompiledColumn<Row>) => string;` | optional | Computes the header text from the compiled column. Called once per column compile; its result replaces `header` everywhere header text is shown or exported. |
| `align` | `readonly align?: 'start' \| 'center' \| 'end' \| 'justify';` | optional |  |
| `headerAlign` | `readonly headerAlign?: 'start' \| 'center' \| 'end';` | optional |  |
| `width` | `readonly width?: ColumnWidth;` | optional |  |
| `minWidth` | `readonly minWidth?: number;` | optional |  |
| `maxWidth` | `readonly maxWidth?: number;` | optional |  |
| `hidden` | `readonly hidden?: boolean;` | optional | Default false. Runtime visibility is state in the `columns` module. |
| `pinned` | `readonly pinned?: 'start' \| 'end' \| 'center';` | optional | Logical pin side: `start` is the left zone in LTR, `end` the right zone, `center` the fixed zone (the column stays at its scroll-start position while the center columns scroll on both sides of it). |
| `lockPosition` | `readonly lockPosition?: boolean;` | optional | Fixed at the start of its zone, not reorderable. |
| `sortable` | `readonly sortable?: boolean;` | optional |  |
| `filterable` | `readonly filterable?: boolean;` | optional |  |
| `searchable` | `readonly searchable?: boolean;` | optional |  |
| `groupable` | `readonly groupable?: boolean;` | optional |  |
| `groupByFormat` | `readonly groupByFormat?: boolean;` | optional | Group by the formatted value (`format`) instead of the raw value. |
| `groupKey` | `readonly groupKey?: (row: Row) => unknown;` | optional | Custom group key: rows group by this per-row value instead of the column value (`groupByFormat` is then ignored for bucketing). Local data only; groups order by key. See docs/site/content/grouping.md. |
| `editable` | `readonly editable?: boolean;` | optional |  |
| `resizable` | `readonly resizable?: boolean;` | optional |  |
| `reorderable` | `readonly reorderable?: boolean;` | optional |  |
| `primaryKey` | `readonly primaryKey?: boolean;` | optional |  |
| `identity` | `readonly identity?: boolean;` | optional | Server-generated key. |
| `defaultValue` | `readonly defaultValue?: unknown;` | optional | Value of the column in a row added through editing. |
| `editor` | `readonly editor?: string;` | optional | Editor preset name: `text`, `number`, `select`, `checkbox`, `date`, `datetime`, or a registered custom editor. Inferred from `type` when absent. |
| `editorProps` | `readonly editorProps?: {     readonly [key: string]: unknown; };` | optional | Props of the built-in editor, passed to the editor as is. |
| `validation` | `readonly validation?: ColumnValidation<Row, ValidatorContext<Row, CompiledColumn<Row>>>;` | optional | Validation rules. |
| `displayAsCheckbox` | `readonly displayAsCheckbox?: boolean;` | optional |  |
| `hideable` | `readonly hideable?: boolean;` | optional | Listed in the column chooser. Default true. |
| `valueParser` | `readonly valueParser?: (input: unknown, ctx: ValueContext<Row>) => unknown;` | optional |  |
| `valueFormatter` | `readonly valueFormatter?: (value: unknown, ctx: ValueContext<Row>) => string;` | optional |  |
| `clipboardFormatter` | `readonly clipboardFormatter?: (value: unknown, ctx: ValueContext<Row>) => string;` | optional |  |
| `sortComparator` | `readonly sortComparator?: (a: unknown, b: unknown, rowA: Row, rowB: Row) => number;` | optional |  |
| `filterComparator` | `readonly filterComparator?: (value: unknown, filterValue: Json, operator: FilterOperator) => boolean;` | optional | Custom filter comparer: replaces the built-in test of every built-in operator on this column. Called once per distinct cell value with the raw value, the condition's value, and the camelCase operator; returns whether the value matches. Local data only. |
| `lookup` | `readonly lookup?: ColumnLookup;` | optional | Lookup (foreign-key) column; needs the `lookup` module. |
| `columns` | `readonly columns?: readonly ColumnDef<Row>[];` | optional | Stacked header group: child definitions. |
| `meta` | `readonly meta?: Json;` | optional |  |
