@jsvision/datagrid / column
Function: column()
column<
T,V>(col):GridColumn<T>
Defined in: datagrid/src/column.ts:200
Author a typed column. Infers the value type V from value, so format/parse are type-checked against it, then returns the column in the uniform storage shape so differently-typed columns collect into one GridColumn<T>[].
Authoring is per column, not per array: a per-array helper would collapse every element to unknown, leaving a typed format/parse uncheckable.
Type Parameters
T
T
V
V
Parameters
col
GridColumn<T, V>
The column definition (id, title, value, and optional format/parse/width/align).
Returns
GridColumn<T>
The same column, typed for collection into a GridColumn<T>[].
Example
ts
import { column } from '@jsvision/datagrid';
interface Person { name: string; balance: number; }
const eur = new Intl.NumberFormat('nl-NL', { style: 'currency', currency: 'EUR' });
const columns = [
column({ id: 'name', title: 'Name', value: (r: Person) => r.name }),
column({
id: 'balance',
title: 'Balance',
value: (r: Person) => r.balance, // v is inferred as number
format: (v) => eur.format(v),
align: 'right',
}),
];