Editing Plugin
Configure editable columns and listen for edit events.
The editing plugin is installed automatically. Mark columns as editable and listen for edit events to update your data source.
Column Setup
import type { ColumnDef } from '@zengrid/core';
const columns: ColumnDef[] = [ { field: 'name', header: 'Name', width: 220, editable: true, editor: 'text' }, { field: 'age', header: 'Age', width: 100, editable: true, editor: 'number' }, { field: 'active', header: 'Active', width: 100, editable: true, editor: 'checkbox' },];Editor Options
const columns: ColumnDef[] = [ { field: 'role', header: 'Role', width: 150, editable: true, editor: 'select', editorOptions: { options: [ { value: 'admin', label: 'Administrator' }, { value: 'editor', label: 'Editor' }, { value: 'viewer', label: 'Viewer' }, ], }, },];Events
grid.on('edit:start', ({ cell, value }) => { console.log('start', cell, value);});
grid.on('edit:commit', ({ cell, oldValue, newValue }) => { rows[cell.row][cell.col] = newValue; console.log('commit', oldValue, newValue);});
grid.on('edit:cancel', ({ cell }) => { console.log('cancel', cell);}); ℹ Info
The public events are edit:start, edit:end, edit:commit, and edit:cancel.