gridcn1.2.2

Action buttons

The action-buttons column pattern (inline Edit/Delete buttons and a more dropdown, composed over store actions).

The action-buttons column: a pinned-right readOnly column whose renderCell composes plain shadcn Buttons over store actions. Every button calls an existing store action, and the column's readOnly: true keeps the grid from ever trying to edit it.

Each row's pinned-right column offers inline Edit / Delete buttons plus a "more" dropdown (Edit, Duplicate, Delete) — all plain store actions.

Name
Role
Age
Actions
Silent Tiger
Viewer
63
Quick Lion
Viewer
67
Swift Wolf
Manager
40
Eager Lion
User
50
Eager Tiger
Viewer
45
Silent Wolf
User
24
pnpm dlx shadcn@latest add @gridcn/data-grid-actions-demo

The two patterns

PatternGood forTrade-off
Inline buttons (Edit, Delete)1–2 actions every row always usesTakes horizontal space per row
"More" dropdown3+ actions, or rarely-used onesOne extra click per action

The demo ships both: two always-visible icon buttons plus a dropdown carrying the same Edit and a Duplicate.

How it's wired

{
  id: "actions",
  header: "",
  pin: "right",
  readOnly: true,
  width: 110,
  renderCell: ({ viewRowIndex }) => <RowActions rowIndex={viewRowIndex} />,
}

Inside RowActions (inside the provider):

const actions = useDataGridActions();

// Edit drops the row's first editable cell into edit mode
actions.startEditingAt({ row: rowIndex, col: 0 });

// Duplicate/delete work on view-space indices — the same space renderCell's viewRowIndex is in
actions.duplicateRows([rowIndex]);
actions.deleteRows([rowIndex]);

viewRowIndex is the view-index position, exactly what the row-operation actions expect (no index translation needed). Cell actions like startEditing take a stable CellRef ({ rowId, columnId }) by default; the *At variants take the viewRowIndex/column position instead. Target the row by identity through rowId (in renderCell's props) whenever the action needs something beyond its position.

Behavior reference

On this page