Skip to content

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).

Inline Editing & Edit Sessions
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();
};
}

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 original Date reference if unmodified).
  • grid.startEditing(cell) / commitEditing(newValue) / cancelEditing(): Control edit sessions programmatically.
  • grid.getEditSession(): Inspect token, rowId, colId, dataEpoch, modelVersion, initialValue, and validationMessage.
  • 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, editSessionChanged fires with 'recycle', 'dataChange', 'columnChange', or 'stale'.