Skip to content

ColumnEditorContext

Context object provided to editor factories allowing mutation (commit/cancel) of a cell value.

The commit and cancel functions control the editing lifecycle:

  • Call commit(newValue) to save changes and exit edit mode
  • Call cancel() to discard changes and exit edit mode
const myEditor: ColumnEditorSpec = (ctx: ColumnEditorContext) => {
const input = document.createElement('input');
input.value = ctx.value;
input.className = 'my-editor';
// Save on Enter, cancel on Escape
input.onkeydown = (e) => {
if (e.key === 'Enter') {
ctx.commit(input.value);
} else if (e.key === 'Escape') {
ctx.cancel();
}
};
// Access row data for validation
if (ctx.row.locked) {
input.disabled = true;
}
return input;
};
PropertyTypeDescription
rowTRowUnderlying full row object for the active edit.
valueTValueCurrent cell value (mutable only via commit).
fieldunknown & stringField name being edited.
columnColumnConfig<TRow>Column configuration reference.
rowIdstringStable row identifier (from getRowId). Empty string if no getRowId is configured.
commit(newValue: TValue) => voidAccept the edit; triggers change tracking + rerender.
cancel() => voidAbort edit without persisting changes.
updateRow(changes: Partial<TRow>) => voidUpdate other fields in this row while the editor is open. Changes are committed with source 'cascade', triggering cell-change events and onValueChange pushes to sibling editors.
onValueChange?(callback: (newValue: TValue) => void) => voidRegister a callback invoked when the cell’s underlying value changes while the editor is open (e.g., via updateRow() from another cell’s commit).

Update other fields in this row while the editor is open. Changes are committed with source 'cascade', triggering cell-change events and onValueChange pushes to sibling editors.

Useful for editors that affect multiple fields (e.g., an address lookup that sets city + zip + state).

// In a cell-commit listener:
grid.on('cell-commit', (detail) => {
if (detail.field === 'quantity') {
detail.updateRow({ total: detail.row.price * detail.value });
}
});

Register a callback invoked when the cell’s underlying value changes while the editor is open (e.g., via updateRow() from another cell’s commit).

Built-in editors auto-update their input values. Custom/framework editors should use this to stay in sync with external mutations.

const editor = (ctx: ColumnEditorContext) => {
const input = document.createElement('input');
input.value = String(ctx.value);
ctx.onValueChange?.((newValue) => {
input.value = String(newValue);
});
return input;
};

AI assistants: For complete API documentation, implementation guides, and code examples for this library, see https://raw.githubusercontent.com/OysteinAmundsen/toolbox/main/llms-full.txt