ColumnConfig
Column configuration for React applications.
Extends the base ColumnConfig with renderer and editor properties
that accept React render functions returning JSX.
Example
Section titled “Example”import type { GridConfig, ColumnConfig } from '@toolbox-web/grid-react';
const columns: ColumnConfig<Employee>[] = [ { field: 'name', header: 'Name' }, { field: 'status', header: 'Status', renderer: (ctx) => <StatusBadge value={ctx.value} />, editor: (ctx) => ( <StatusSelect value={ctx.value} onCommit={ctx.commit} onCancel={ctx.cancel} /> ), },];Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
field | unknown & string | Unique field key referencing property in row objects |
header? | string | Visible header label; defaults to capitalized field |
type? | ColumnType | Column data type. |
width? | string | number | Column width in pixels; fixed size (no flexibility) |
minWidth? | number | Minimum column width in pixels (stretch mode only); when set, column uses minmax(minWidth, 1fr) |
sortable? | boolean | Whether column can be sorted |
resizable? | boolean | Whether column can be resized by user |
sortComparator? | (a: any, b: any, rowA: TRow, rowB: TRow) => number | Optional custom comparator for sorting (a,b) -> number |
options? | object[] | () => object[] | For select type - available options |
multi? | boolean | For select - allow multi select |
format? | (value: any, row: TRow) => string | Formats the raw cell value into a display string. |
meta? | Record<string, unknown> | Arbitrary extra metadata |
externalView? | object | External view spec (lets host app mount any framework component) |
hidden? | boolean | Whether the column is initially hidden |
lockVisible? | boolean | Prevent this column from being hidden programmatically |
cellClass? | (value: unknown, row: TRow, column: ColumnConfig<TRow>) => string | string[] | Dynamic CSS class(es) for cells in this column. Called for each cell during rendering. Return class names to add to the cell element. |
editable? | boolean | Whether the field is editable (enables editors). Requires EditingPlugin. |
editorParams? | EditorParams | Configuration parameters for built-in editors. Shape depends on column type (NumberEditorParams, TextEditorParams, DateEditorParams, SelectEditorParams). Requires EditingPlugin. |
nullable? | boolean | Whether this column allows null values. Requires EditingPlugin. |
filterable? | boolean | Whether this column can be filtered (only applicable when FilteringPlugin is enabled). |
filterParams? | FilterParams | Configuration for the filter UI (only applicable when FilteringPlugin is enabled). For number columns: { min, max, step } For date columns: { min, max } (ISO date strings) Falls back to editorParams if not set. |
filterValue? | (value: unknown, row: any) => unknown | Custom value extractor for filtering. Use this when the cell value is a complex type (e.g., an array of objects) and the filter should operate on derived primitive values instead. |
group? | string | object | Column group assignment for the GroupingColumnsPlugin. Columns with the same group.id are rendered under a shared header. |
pinned? | PinnedPosition | Pin column to an edge of the grid. |
sticky? | PinnedPosition | ⚠️ |
printHidden? | boolean | Hide this column when printing (default: false). Use this to exclude interactive or less important columns from print output. |
renderer? | (ctx: CellRenderContext<TRow>) => ReactNode | React component renderer for cell display. Receives cell context and returns a React node (JSX). |
editor? | (ctx: ColumnEditorContext<TRow>) => ReactNode | React component editor for cell editing. Receives editor context with commit/cancel functions and returns a React node (JSX). |
headerRenderer? | (ctx: HeaderCellContext<TRow>) => ReactNode | React component header renderer for full header cell control. Receives header cell context and returns a React node (JSX). |
headerLabelRenderer? | (ctx: HeaderLabelContext<TRow>) => ReactNode | React component header label renderer for customizing just the label portion. Receives header label context and returns a React node (JSX). |
Property Details
Section titled “Property Details”Column data type.
Built-in types: 'string', 'number', 'date', 'boolean', 'select'
Custom types (e.g., 'currency', 'country') can have type-level defaults
via gridConfig.typeDefaults or framework adapter registries.
Default: Inferred from first row data
format
Section titled “format”Formats the raw cell value into a display string.
Used both for cell rendering and the built-in filter panel:
- In cells, the formatted value replaces the raw value as text content.
- In the filter panel (set filter), checkbox labels show the formatted value instead of the raw value, and search matches against the formatted text.
The row parameter is available during cell rendering but is undefined
when called from the filter panel (standalone value formatting). Avoid
accessing row properties in format functions intended for filter display.
// Currency formatter — works in both cells and filter panel{ field: 'price', format: (value) => `$${Number(value).toFixed(2)}`,}
// ID-to-name lookup — filter panel shows names, not IDs{ field: 'departmentId', format: (value) => departmentMap.get(value as string) ?? String(value),}cellClass
Section titled “cellClass”// Highlight negative valuescellClass: (value, row, column) => value < 0 ? ['negative', 'text-red'] : []
// Status-based stylingcellClass: (value) => [`status-${value}`]
// Single class as stringcellClass: (value) => value < 0 ? 'negative' : ''editorParams
Section titled “editorParams”{ field: 'price', type: 'number', editable: true, editorParams: { min: 0, max: 1000, step: 0.01 } }nullable
Section titled “nullable”Whether this column allows null values. Requires EditingPlugin.
When true:
- Text/number editors: clearing all content commits
null. - Select editors: a “(Blank)” option is automatically prepended that
commits
null. The label defaults to"(Blank)"and can be overridden viaSelectEditorParams.emptyLabel. - Date editors: clearing the date commits
null.
When false:
- Text editors: clearing commits
""(empty string). - Number editors: clearing commits
editorParams.minif set, otherwise0. - Select editors: no blank option is shown, forcing a selection.
- Date editors: clearing commits
editorParams.defaultif set, otherwise today’s date. The fallback preserves the original type (string →"YYYY-MM-DD", Date →new Date()).
When omitted (default), behaviour matches false for text/number columns
and no special handling is applied.
Custom editors can read column.nullable from the ColumnEditorContext
to implement their own nullable behaviour.
Default: false
columns: [ { field: 'nickname', editable: true, nullable: true }, { field: 'department', type: 'select', editable: true, nullable: true, options: [{ label: 'Engineering', value: 'eng' }, { label: 'Sales', value: 'sales' }] }, { field: 'price', type: 'number', editable: true, nullable: false, editorParams: { min: 0 } }, // clears to 0 { field: 'startDate', type: 'date', editable: true, nullable: false, editorParams: { default: '2024-01-01' } }, // clears to Jan 1 2024]filterable
Section titled “filterable”Default: true
filterValue
Section titled “filterValue”Custom value extractor for filtering. Use this when the cell value is a complex type (e.g., an array of objects) and the filter should operate on derived primitive values instead.
The function receives the raw cell value and the full row, and should return either a single filterable value or an array of filterable values. When an array is returned, each element becomes an individual entry in the filter panel’s unique values list. During filtering:
notIn(set filter): row is hidden if ANY extracted value is in the excluded setin(set filter): row passes if ANY extracted value is in the included set
// Array-of-objects column: extract individual names for filtering{ field: 'sellers', filterValue: (value) => (value as { companyName: string }[])?.map(s => s.companyName) ?? [], format: (value) => (value as { companyName: string }[])?.map(s => s.companyName).join(', ') ?? '',}printHidden
Section titled “printHidden”columns: [ { field: 'name', header: 'Name' }, { field: 'actions', header: 'Actions', printHidden: true }, // Hidden in print]