Batch-editing runtime switch
Prop enableBatchEditing — engine behaviour, default — (follows enableEditing.mode).
Guide
When to use it
Reach for batch mode when users enter or correct many cells before saving — bulk data entry, reconciliation, spreadsheet-style workflows — and you want one backend write, not one per cell.
How it works
enableBatchEditing flips the edit mode at runtime: true forces batch, false forces
per-cell, and leaving it unset follows enableEditing.mode. In batch mode every edit and paste
becomes an unsaved draft; nothing reaches your backend until an explicit save fires onSave
once with the whole change-set:
<BstTableMui
data={rows}
columns={columns}
getRowId={(r) => r.id}
enableEditing
enableBatchEditing
showChangesSheet
onSave={async ({ changes, rows }) => {
await api.bulkUpdate(rows.map((r) => r.patch)) // ONE call, never per-cell
}}
/>
Pair it with showChangesSheet so users can review every pending edit (row · column · old → new)
and revert individually before committing.
Gotchas
- Requires
enableEditing— it's a switch over the edit session, not a replacement for it. - A rejected
onSavekeeps every draft intact; surface the error and let the user retry. - It appears in the settings sheet ("Editing"), so a
{ mode: 'batch' }grid reads as ON there.
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: 'batch' }} enableBatchEditing showChangesSheet
onDataChange={setRows}
onSave={({ rows }) => alert(rows.length + ' row(s) saved in one call')} />
)
}
Overview
| Layer | enable* (engine, resolved in useBstTable) |
| Type | boolean |
| Default | — (follows enableEditing.mode) |
| Maps to | overrides the editing mode at runtime: true forces 'batch', false forces a batch grid back to per-cell; unset follows enableEditing.mode. In the settings sheet ("Editing", alwaysShow) via the new SETTINGSMETA.getBase hook, so the switch truthfully reflects a { mode: 'batch' } grid as ON; adapters' review-sheet chrome follows it. |
| Status | ✅ done |
| Since | v0.32.0 |
| Settings sheet | Editing |
Batch editing (runtime switch for enableEditing.mode: 'batch'). When set it OVERRIDES the configured editing mode: true forces batch mode (every edit stays an unsaved draft until the explicit Review & save), false forces a batch-configured grid back to per-cell commits. Leave unset to follow enableEditing.mode. Needs enableEditing; this is the flag the settings sheet toggles ("Editing" group), so end-users can switch batch mode per table.
Enable it
<BstTableMui
data={rows}
columns={columns}
enableBatchEditing
/>
Swap
BstTableMuiforBstTableShadcn(and the CSS import) for the shadcn skin — same props.
Options
| Option | Notes |
|---|---|
onSave | batch mode defers every edit to one explicit save; without onSave nothing is persisted |
Behavior & interactions
- Requires
enableEditingto be on — this flag is a no-op otherwise. - Overrides
enableEditing.modeat runtime.onSavefires ONCE per save action with the whole change set — make one backend request from it, never one per cell.