Per-row options and editors
You can decide a select column's options or the editor kind per row (1.3.6). It is decided when the editor opens (edit start, paste parsing), not when cells are drawn.
Options per row
{
id: 'item',
title: 'Item',
kind: 'select',
editable: true,
editorOptions: ({ row }) => (row.kind === 'fruit' ? [{ value: 'apple' }, { value: 'pear' }] : [{ value: 'carrot' }]),
}- The function gets
{ row, rowKey, columnId }and returns an array of{ value, label? }. - An empty list keeps the editor closed and fires
validationFailed("There are no options for this row."). The cell shows the rejected mark. - If the callback throws or returns a non-array, the editor does not open and a
callback-erroris reported. - With a function, the "non-empty list" check is skipped when options are applied (a fixed array is still checked).
Build the list from another column
{ id: 'city', title: 'City', kind: 'select', editable: true, optionsFrom: 'region' }optionsFrom is the id of another column. Its non-empty values are taken in first-seen order, as they are when the editor opens. The label is that column's shown text. Itself or an unknown column is an invalid-option.
Display text of a stored value
{ id: 'dept', kind: 'select', editorOptions: [{ value: 'D01' }, { value: 'D02' }], optionLabel: (value) => NAMES[value] ?? String(value) }optionLabel(value, row) is the text the cell shows when there is no formatValue or format. It is also the copied text, the exported text, the group name and the label in the filter menu and filter row value lists (values stay as they are). It fills the editor list text of items without a label. It runs per cell, so keep it cheap.
Choose the editor per row
{
id: 'value',
cellEditor: 'text',
cellEditorFor: ({ row }) => (row.type === 'choice' ? 'select' : 'text'),
editorOptions: ({ row }) => row.choices,
}cellEditorFor returns an editor key ('text', 'select' ...) or an editor factory. cellEditor already accepts a function (a factory), so the two function forms cannot be told apart; that is why this is a separate key. When both are set, cellEditorFor is used for editing and cellEditor where a default is needed (validation, display). If it throws or returns an unknown value, that cell does not open and a callback-error is reported. editorParams stays one per column.
Paste also reads text with that row's editor kind and options. The renderer that draws the cell is not chosen per row (one per column).
Reset child columns when the parent changes
A column whose value follows an earlier one, such as a city or a postal code, gets cascade on the parent column (1.4.0).
{ id: 'country', editable: true, cascade: { children: ['city', 'zip'], reset: 'clear' } }| Key | Value | Default | Effect |
|---|---|---|---|
children | array of column ids (not empty) | required | Child columns to reset; an unknown id, a duplicate or the column itself fails at creation with invalid-option |
reset | 'clear' · 'default' · (childId, row) => value | 'clear' | clear empties (follows emptyAs), default uses the child's defaultValue, a function uses its result |
| Case | Behavior |
|---|---|
| When | After an editor commit, a paste or a clear key actually changes the parent; an equal value does nothing |
| Undo | Parent and children are one undo step; the child writes are also announced as editCommitted |
| Non-editable children | A child with editable: false is reset too (it is a data rule) |
| Validation | The new value is validated after the reset; a failure reports validationFailed for that cell and skips the reset. The parent commit stays |
| Chaining | A child's own cascade is not triggered (avoids loops) |
updateCells writes | Do not cascade |
To build a child's list from the parent value, use an editorOptions function that reads the parent from row. It is read again when the editor opens, so opening after the parent changed shows the new list.
{ id: 'city', editable: true, cellEditor: 'select',
editorOptions: ({ row }) => CITIES[row.country] ?? [] }Gallery example: edit-cascade-reset
Gallery example: edit-cascade-default