Editing Basics
Set isEditable: true (or a callback (params: CellEditParams<T>) => boolean) on any column to enable inline editing via double-click, Enter, F2, or typing a printable character (IME compositions are ignored until committed).
import { Grid, type ColumnDef } from 'next-grid-js';import { createOrders, type OrderRow } from './data/orders';import { syncGridTheme } from './theme';import type { DemoMountContext } from './types';
export function mount({ stage, meta }: DemoMountContext): () => void { const columnDefs: readonly ColumnDef<OrderRow>[] = [ { key: 'id', name: 'ID', width: 96, }, { key: 'customer', name: 'Customer', width: 175, flex: 1, isEditable: true, }, { key: 'quantity', name: 'Qty', width: 85, cellDataType: 'number', isEditable: true, }, { key: 'orderedAt', name: 'Order Date', width: 120, cellDataType: 'date', isEditable: true, }, { key: 'status', name: 'Status', width: 110, isEditable: true, }, ];
const grid = new Grid<OrderRow>({ container: stage, columnDefs, rowData: createOrders(25), getRowId: (row) => row.id, }); const stopTheme = syncGridTheme(stage);
grid.addEventListener('editSessionChanged', ({ session, reason }) => { meta.textContent = session ? `Editing ${session.rowId} · ${session.colId} (${reason})` : `Session ended (${reason})`; }); meta.textContent = 'Double-click a cell, press Enter, or press F2 to edit';
return () => { grid.destroy(); stopTheme(); };}Built-in Editors by cellDataType
Section titled “Built-in Editors by cellDataType”When cellEditor and editor are omitted, NextGrid creates a built-in editor based on cellDataType:
'boolean'(or'auto'on boolean values):<select>with'','True', and'False'.'number':<input type="text" inputMode="decimal">.'date'/'dateTime'/'text'/'auto':<input type="text">(preserving the originalDatereference if unmodified).
Edit Sessions & Programmatic API
Section titled “Edit Sessions & Programmatic API”grid.startEditing(cell)/commitEditing(newValue)/cancelEditing(): Control edit sessions programmatically.grid.getEditSession(): Inspecttoken,rowId,colId,dataEpoch,modelVersion,initialValue, andvalidationMessage.- Rebinding & Scroll: Active editors remain mounted cleanly across frame rebinds; if the cell scrolls out of the recycled pool or its row/column is replaced,
editSessionChangedfires with'recycle','dataChange','columnChange', or'stale'.