Context menu
View sourceRight-click any cell or row to open the grid's context menu. Mix custom items with bc-grid's built-in actions (copy / clear / pin / autosize) without writing chrome from scratch.
Right-click any row. The first three items are dynamic per-row; Copy cell / range / sep are bc-grid built-ins.No action yet
Try this
The first two items are dynamic per-row; the rest are bc-grid built-ins + a destructive item.
- Right-click any cell on a data row.
- The first item shows the customer name (per-row).
- Click Copy "…" — the row id is copied to your real clipboard.
- Hover Copy cell / Copy row — built-in clipboard items, no consumer wiring.
- The destructive item renders in red and only shows when the click is on a row.
Item shapes
- Built-in (string). Just pass the string id —
"copy","copy-cell","clear-all-filters","pin-column-left","separator", etc. The grid wires the action. - Custom.
{ id, label, onSelect, disabled?, variant? }. Receives aBcContextMenuContextwith{ row, rowId, column, cell, selection, api }. - Toggle.
{ kind: "toggle", id, label, checked, onSelect }for boolean preferences (Show pagination, Show inactive rows, etc.). Wires through the user-settings store. - Submenu.
{ kind: "submenu", id, label, items }. Submenu items can be any of the above shapes — nest as deep as you want; the menu collision-flips when a submenu would overflow the viewport.
Items array vs function
- Static array.Same items every right-click. Good for menus that don't care about which row was clicked.
- Function. Receives the
BcContextMenuContextand returns the items list. Use this when items depend on the row, the column, or the selection — like the demo above showing the customer name in the first item. - Filter with falsy. Returning
false,null, orundefinedin the array drops that item — cleaner than filter().
Default menu
If you don't pass contextMenuItems, bc-grid renders DEFAULT_CONTEXT_MENU_ITEMS — Server / Column / View / Editor submenus that cover the common-case actions every ERP grid wants out of the box. Import the constant and spread it into your own array if you want to extend rather than replace.