bc-grid
GitHub

Row actions column

View source

A pinned-right action column auto-injected by <BcEditGrid> and <BcServerGrid>. Edit / Delete / Discard ship by default; per-row gating via canEdit / canDelete keeps the chrome consistent without fragile cellRenderer code.

Hover any row to reveal the auto-injected action column on the right.No action yet
Order #
Customer
Sales rep
Status
Amount
Actions
R-000001
Customer 00001
Avery Chen
active
$0.00
R-000002
Customer 00002
Ben Singh
pending
$31.42
R-000003
Customer 00003
Cara Diaz
closed
$62.83
R-000004
Customer 00004
Drew Lin
active
$94.25
R-000005
Customer 00005
Elena Park
pending
$125.66
R-000006
Customer 00006
Felix Roy
closed
$157.08
R-000007
Customer 00007
Gita Bose
active
$188.50
R-000008
Customer 00008
Henry Kao
pending
$219.91
R-000009
Customer 00009
Avery Chen
closed
$251.33
R-000010
Customer 00010
Ben Singh
active
$282.74
R-000011
Customer 00011
Cara Diaz
pending
$314.16
R-000012
Customer 00012
Drew Lin
closed
$345.57
R-000013
Customer 00013
Elena Park
active
$376.99
R-000014
Customer 00014
Felix Roy
pending
$408.41
R-000015
Customer 00015
Gita Bose
closed
$439.82

Try this

The action column lives at the right edge — pinned, auto-injected, no consumer wiring.

  • Hover any row — the action chrome reveals on the right.
  • Click Edit — fires onEdit(row); the demo logs to the bar.
  • Click Delete — fires onDelete(row) and removes the row from local state.
  • The Delete button is greyed-out for active orders — that's canDelete(row) in action.
  • Hover a row, then press Shift+E to invoke Edit, Shift+Delete for Delete — built-in keyboard shortcuts.

Why an injected column

Pre-bc-grid wrappers in bsncraft hand-rolled the same actions column over and over per grid — ~40 LOC each, all subtly different. Lifting it to the grid solves three problems at once: consistent visual + keyboard chrome across all grids, server-grid parity (the column ships on <BcServerGrid> too), and per-row gating colocated with the row data.

Available props

  • onEdit / onDelete. Required (one or both) to mount the column. Each receives the row.
  • canEdit / canDelete. Per-row gates returning boolean. Disabled buttons render but don't fire the handler.
  • editLabel / deleteLabel. Custom button labels. Defaults "Edit" / "Delete".
  • onDiscardRowEdits. Adds a Discard action that rolls back pending row edits — typically (rowId) => apiRef.current?.discardRowEdits(rowId).
  • onInsertRow / onDuplicateRow. <BcEditGrid> specific. Wires up insert + duplicate row affordances in the toolbar / context menu.

Keyboard shortcuts

  • Shift+E — invoke Edit on the focused row
  • Shift+Delete or Shift+Backspace — invoke Delete on the focused row