enumOptions
The values an enum column may hold, with the words shown for them.
| Type | readonly EnumOption[] |
|---|---|
| Default | not set |
Live update (update()) | Yes — give the columns again (update({ columns })) |
| Declared in | packages/core/src/columns/defs.ts |
What it does
Section titled “What it does”Each option has a value (what the row holds), a label already translated (what the cell shows; the
value itself without it) and aliases (other words a person may type or paste for it). Typed text matches a value,
a label or an alias whatever its case and accents.
The column sorts by label (by the list’s own order with codec). A value that is not in the list is
shown as it is. An enum column without enumOptions (and without a codec) is
refused with an invalid-column error. When editing, the list editor (editors({ list: listEditor })) offers the options (edit.options can narrow
them per row).
Example
Section titled “Example”import { createGrid } from '@dzgrid/dom';import { EN } from '@dzgrid/dom/locales/en';
type Task = { id: string; title: string; status: string };
createGrid<Task>(document.getElementById('tasks')!, { rows: [{ id: 't1', title: 'Oil the gate', status: 'todo' }], columns: [ { id: 'title', header: 'Task' }, { id: 'status', header: 'Status', type: 'enum', enumOptions: [ { value: 'todo', label: 'To do', aliases: ['open'] }, { value: 'done', label: 'Done', aliases: ['closed'] }, ], }, ], getRowId: (r) => r.id, messages: EN,});