Skip to main content

Row add/delete/duplicate

Prop enableRowActions — engine behaviour, default false.

Guide

When to use it

Turn this on when users need to add, delete or duplicate rows — the structural edits that go beyond changing cell values.

How it works

enableRowActions wires up row add / delete / duplicate, each routed through onDataChange. An optional createRow factory seeds a new row's defaults:

<BstTableMui
data={rows}
columns={columns}
getRowId={(r) => r.id}
enableRowActions
showAddRow
createRow={() => ({ id: crypto.randomUUID(), name: '', qty: 0 })}
onDataChange={(next) => setRows(next)}
/>

Add showAddRow for the toolbar "Add row" button; per-row delete / duplicate live in the row's action column or the actionMenu cell.

Gotchas

  • Needs onDataChange so the structural change reaches your state.
  • Without createRow, a new row starts empty — fine, but wire it up if columns have required defaults.
  • New rows still go through validation and (in batch mode) the change-set like any other edit.

Live example

Row actions — add / edit / delete (incl. action cells)

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 withAction: BstTableColumn<Row>[] = [...columns, { id: 'actions', accessorKey: 'id', header: 'Actions', meta: { type: 'action' } }]
export default function App() {
const [rows, setRows] = React.useState(seed)
return (
<BstTableMui data={rows} columns={withAction} getRowId={(r) => r.id}
enableEditing enableRowActions showAddRow onDataChange={setRows} />
)
}
Loading live example…

Overview

Layerenable* (engine, resolved in useBstTable)
Typeboolean
Defaultfalse
Maps tocustom feature
Status✅ done (Phase 2)
Sincev0.2.0
Settings sheetEditing

Row add/delete/duplicate lifecycle. Default: false (opt-in).

Enable it

<BstTableMui
data={rows}
columns={columns}
enableRowActions
/>

Swap BstTableMui for BstTableShadcn (and the CSS import) for the shadcn skin — same props.

Options

OptionNotes
onDataChangeadd/delete/duplicate must write back to your data

Behavior & interactions

  • Supply createRow to control the shape of a newly added row.