<Toolbar>, <ContextMenu>, and <HeaderMenu> — that all connect to the Gantt through the shared api prop.
Toolbar
<Toolbar> renders a row of action buttons above (or anywhere around) the chart.
Basic setup
Default toolbar buttons
CallgetToolbarButtons() to retrieve the default button descriptors. Each button has an id that maps directly to a Gantt action name.
| Button id | Action triggered |
|---|---|
add-task | add-task |
indent-task | indent-task |
outdent-task | outdent-task |
move-task:up | move-task (mode: up) |
move-task:down | move-task (mode: down) |
delete-task | delete-task |
undo | undo |
redo | redo |
Customising toolbar buttons
Filter out unwanted buttons, add your own, and pass the result as theitems prop.
Fully custom toolbar
For full control, skip<Toolbar> entirely and build your own toolbar with standard React state and api.exec(). Subscribe to the reactive state store to track selection changes:
Context menu
<ContextMenu> wraps the <Gantt> as a child and shows a right-click menu on task rows.
Basic setup
Default menu options
id values you can reference:
| id | Description |
|---|---|
add-task:before | Add task above |
add-task:after | Add task below |
add-task:child | Add child task |
cut-task | Cut task |
copy-task | Copy task |
paste-task | Paste task |
delete-task | Delete task |
Customising menu options
Pass a customoptions array to replace the defaults. Mix default options (looked up by id) with your own:
Filtering menu items per task
Use thefilter prop to show or hide menu items based on the right-clicked task:
resolver prop controls which tasks trigger the menu. Return false to suppress the menu for a given task id:
HeaderMenu
<HeaderMenu> wraps the Gantt (or any grid-based widget) and adds a right-click menu on column headers for toggling column visibility.
columns array to control which columns appear in the visibility toggle list:
Intercepting actions (onaction)
All toolbar and context menu built-in actions route throughapi.exec(). You can intercept them before they execute using api.intercept():
api.intercept(), api.on(), and api.exec().
Props reference
Toolbar
| Prop | Type | Default | Description |
|---|---|---|---|
api | IApi | null | Gantt API instance. |
items | array | [] | Button descriptors. Falls back to getToolbarButtons() when empty. |
ContextMenu
| Prop | Type | Default | Description |
|---|---|---|---|
api | IApi | null | Gantt API instance. |
options | array | [] | Menu item descriptors. Falls back to getMenuOptions() when empty. |
resolver | function | null | (id, ev) => task | boolean — controls which tasks get a menu. |
filter | function | null | (item, task) => boolean — per-task menu item visibility. |
onClick | function | — | ({ context, action }) => void — called when a menu item is clicked. |
at | string | 'point' | Positioning strategy for the menu popup. |
HeaderMenu
| Prop | Type | Default | Description |
|---|---|---|---|
api | IApi | — | Gantt API instance used to resolve the table API. |
columns | array | null | Column descriptors to display in the visibility toggle. |