Skip to content

@jsvision/datagrid / createCellEditor

Function: createCellEditor()

createCellEditor<T>(column, field, host, row?): View | null

Defined in: datagrid/src/cell-editor.ts:145

Build the editor view for a cell, two-way bound to field. Returns null when the column is read-only (no parse/set) or its editor resolves to { kind: 'readonly' }, which the caller treats as "reject begin-edit". Otherwise the column's editor descriptor selects the widget; with no descriptor an editable column mounts a single-line text Input, exactly as before.

Type Parameters

T

T

Parameters

column

GridColumn<T>

The typed column being edited.

field

Signal<string>

The edit-buffer signal (seeded from the cell, parsed back on commit).

host

CellEditorHost

What a richer editor uses to open a sub-popup, and what a custom factory receives; ignored by the text/numeric inputs.

row?

T

The row being edited, used to resolve a per-row editor function; omit for a static spec.

Returns

View | null

A focusable editor view bound to field, or null for a read-only column.

Example

ts
import { Group, signal } from '@jsvision/ui';
import { column, createCellEditor } from '@jsvision/datagrid';
interface Product { qty: number; }
const qty = column({
  id: 'qty', title: 'Qty', value: (r: Product) => r.qty,
  parse: (t) => Number(t), set: (r, v) => { r.qty = v; },
  editor: { kind: 'integer' }, // a digits-only keystroke filter
});
const field = signal('7');
const editor = createCellEditor(qty, field, { overlay: new Group() }); // a filtered Input bound to `field`