Inline editing
Prop enableEditing — engine behaviour, default false.
Guide
When to use it
Turn this on whenever cells should be editable in place. It's the foundation of the whole editing layer — validation, undo/redo, row actions and the batch review sheet all build on it.
How it works
enableEditing opens an edit session on a cell (or row) and writes the result back through
your handler. Choose the granularity with the mode option:
<BstTableMui
data={rows}
columns={columns}
getRowId={(r) => r.id}
enableEditing={{ mode: 'cell' }} // 'cell' | 'row' | 'batch'
onDataChange={(next) => setRows(next)}
/>
cellcommits on Enter / blur;rowcommits the row as a unit;batchkeeps every edit as a draft until an explicit save (seeenableBatchEditing).- Editability is per column via
meta.editable; a column with no editor stays read-only.
Gotchas
- Always pass
getRowId. Edits target rows by id — without it, a sort or filter can send a commit to the wrong row. - Committed edits need somewhere to go:
onDataChange(inline modes) oronSave(batch). Without a handler the edit has nowhere to land. enableEditingalone doesn't validate. AddenableValidationto block or flag bad input.
Live example
Example source
import React from 'react'
import { BstTableMui } from '@bloomskill/table-mui'
import type { BstTableColumn } from '@bloomskill/table-engine'
import '@bloomskill/table-engine/styles.css'
type Row = { id: string; name: string; team: string; role: string; score: number }
const seed: Row[] = [
{ id: '1', name: 'Ada Lovelace', team: 'Platform', role: 'Engineer', score: 92 },
{ id: '2', name: 'Alan Turing', team: 'Research', role: 'Scientist', score: 88 },
{ id: '3', name: 'Grace Hopper', team: 'Platform', role: 'Engineer', score: 95 },
{ id: '4', name: 'Katherine J.', team: 'Research', role: 'Analyst', score: 90 },
{ id: '5', name: 'Edsger Dijkstra',team: 'Platform', role: 'Architect',score: 84 },
]
const columns: BstTableColumn<Row>[] = [
{ id: 'name', accessorKey: 'name', header: 'Name' },
{ id: 'team', accessorKey: 'team', header: 'Team' },
{ id: 'role', accessorKey: 'role', header: 'Role' },
{ id: 'score', accessorKey: 'score', header: 'Score', sortFn: 'basic' },
]
const editable: BstTableColumn<Row>[] = columns.map((c) =>
c.id === 'name' || c.id === 'score'
? { ...c, meta: { type: c.id === 'score' ? 'number' : 'text', editable: true } }
: c,
)
export default function App() {
const [rows, setRows] = React.useState(seed)
return (
<BstTableMui data={rows} columns={editable} getRowId={(r) => r.id}
enableEditing={{ mode: 'cell' }} onDataChange={setRows} />
)
}
Loading live example…
Overview
| Layer | enable* (engine, resolved in useBstTable) |
| Type | boolean | {mode,saveOn,policy} |
| Default | false |
| Maps to | custom feature |
| Status | ✅ done (Phase 2) |
| Since | v0.2.0 |
| Settings sheet | Editing |
Inline editing feature. boolean | EditingOptions. Default: false (opt-in).
Enable it
<BstTableMui
data={rows}
columns={columns}
enableEditing={/* boolean | {mode,saveOn,policy} */}
/>
Swap
BstTableMuiforBstTableShadcn(and the CSS import) for the shadcn skin — same props.
Options
| Option | Notes |
|---|---|
getRowId | edits target rows by id, never by index |
onDataChange | without it committed edits have nowhere to go |
Behavior & interactions
- Modes: 'cell' (default, commit per cell) · 'row' (deferred row session) · 'batch' (every edit stays a draft until an explicit save).
Spec coverage
Spec codes (
A1,C2,X8, …) are Bst-Table's internal requirement IDs from the capability matrix;P0–P2mark the delivery phase. They are traceability tags, not part of the public API.
- C2 · Save on Enter/Blur/Explicit — ✅ built. P2
- I2 · Cell events + deferred save — ✅ built. P2 (C2≡I2)
- I4 · Backend updates → cells/rows/grid — ✅ built. both halves done. Send: batch mode's runtime.getChangeSet() + one onSave({ changes, rows[].patch, next }) per save action (v0.30.0), a rejected save keeping every draft. Reconcile: onSave may RETURN a BstSaveResult — applied rows adopt the server's authoritative values (IDs, timestamps, normalised/recomputed fields), failed rows/cells keep their draft + show the error (partial success); returning nothing commits every draft as typed