Skip to content

Gantt Context Menu

Right-click a task to inspect the built-in actions and the custom duplicate, assignment-panel, and workbook actions. The assignment action emits an application event for a host-owned panel.

Source code
import { defineCustomElements } from '@revolist/revogrid/loader';
defineCustomElements();
import { GanttPlugin } from '@revolist/gantt';
import { currentTheme } from '../composables/useRandomData';
import './gantt-example-recipes.css';
import {
RECIPE_ASSIGNMENTS,
RECIPE_CALENDARS,
RECIPE_COLUMNS,
RECIPE_DEPENDENCIES,
RECIPE_GANTT_CONFIG,
RECIPE_PANEL_ROWS,
RECIPE_PANEL_SOURCE_REFERENCES,
RECIPE_RESOURCES,
RECIPE_ROW_CONTEXT_MENU,
RECIPE_TASKS,
attachRecipeValidation,
} from './GanttExampleRecipesShared';
const { isDark } = currentTheme();
function createPanel(): HTMLElement {
const panel = document.createElement('aside');
panel.className = 'gantt-recipe-panel';
panel.innerHTML = `
<div class="gantt-recipe-panel__header">
<strong>Feature recipes</strong>
<span>Live outputs from exported example helpers</span>
</div>
<dl class="gantt-recipe-panel__list">
${RECIPE_PANEL_ROWS.map(
(row) => `
<div>
<dt>${row.label}</dt>
<dd>${row.value}</dd>
</div>
`,
).join('')}
</dl>
<div class="gantt-recipe-panel__sources">
${RECIPE_PANEL_SOURCE_REFERENCES.map((source) => `<code>${source}</code>`).join('')}
</div>
`;
return panel;
}
export function load(parentSelector: string) {
const parent = document.querySelector(parentSelector);
if (!parent) {
return () => {};
}
const root = document.createElement('section');
root.className = 'gantt-recipe-demo';
const grid = document.createElement('revo-grid');
grid.className = 'gantt-recipe-grid';
grid.theme = isDark() ? 'darkCompact' : 'compact';
grid.hideAttribution = true;
grid.plugins = [GanttPlugin];
grid.columns = RECIPE_COLUMNS;
grid.gantt = RECIPE_GANTT_CONFIG;
grid.ganttDependencies = RECIPE_DEPENDENCIES;
grid.ganttCalendars = RECIPE_CALENDARS;
grid.ganttResources = RECIPE_RESOURCES;
grid.ganttAssignments = RECIPE_ASSIGNMENTS;
grid.rowContextMenu = RECIPE_ROW_CONTEXT_MENU;
root.appendChild(grid);
root.appendChild(createPanel());
parent.appendChild(root);
const detachValidation = attachRecipeValidation(grid);
grid.source = RECIPE_TASKS;
return () => {
detachValidation();
root.remove();
};
}

Gantt contributes task and timeline actions through the RevoGrid Pro DataGridContextMenuPlugin; it does not replace your rowContextMenu, columnContextMenu, or dataGridContextMenu configuration. Gantt-compatible shared grid commands are composed first, then dataGridContextMenu.getItems and application items can extend the result.

The integration is enabled by default for every GanttPlugin instance. Set gantt.contextMenu to false to suppress all context menus on the Gantt grid, including generic grid/tree menus and application menu contributions. Their configuration is retained and becomes available again when Gantt context menus are re-enabled:

grid.gantt = {
...project,
contextMenu: false,
};

You can also disable one generated surface at a time:

grid.gantt = {
...project,
contextMenu: {
row: false,
column: true,
},
};

Right-click a task-table row or task bar to open task actions:

  • Add
  • Convert to milestone
  • Indent
  • Outdent
  • Delete

The default actions dispatch Gantt events:

grid.addEventListener('gantt-task-create', (event) => {
const { parentId, insertAfterTaskId } = event.detail ?? {};
});
grid.addEventListener('gantt-task-indent', (event) => {
indentTask(event.detail?.taskId);
});
grid.addEventListener('gantt-task-outdent', (event) => {
outdentTask(event.detail?.taskId);
});
grid.addEventListener('gantt-task-delete', (event) => {
deleteTask(event.detail?.taskId);
});

Add uses the focused row or clicked task bar as the insertion anchor. When the anchor has descendants, Gantt inserts the new sibling after the full descendant block so the task tree stays valid. Context-menu creation names the row New task 1, New task 2, and so on, and does not open the task editor.

The generated row menu is suppressed on the pinned add-task draft row because that row is owned by the internal GanttAddTaskRowPlugin and is not a task entity. If you disable Gantt context-menu integration and provide your own rowContextMenu, use isGanttAddTaskRow() or the draft cell marker to skip that row. See Add Task Row.

The built-in Delete item dispatches the normal Gantt delete command, then Gantt emits the cancelable gantt-before-task-change event with detail.action === 'delete' immediately before it mutates any task. Call preventDefault() to keep the task (and its descendants) unchanged.

grid.addEventListener('gantt-before-task-change', (event) => {
if (event.detail.action !== 'delete') return;
const name = event.detail.previousValues.name ?? 'this task';
if (!window.confirm(`Delete ${name}?`)) {
event.preventDefault();
}
});

This protects deletion initiated from the default context-menu item and direct Gantt delete methods, so it is the preferred place for permission checks and a synchronous browser confirmation. It is called once per affected task; applications that allow bulk deletion should make their confirmation copy clear that descendants may also be removed.

gantt-before-task-change is synchronous. For an asynchronous application modal, prevent the original deletion, keep the selected task ids in application state, and call gantt.deleteTasks(taskIds) only after the user confirms. Guard the follow-up call so the same listener does not reopen the dialog, and recheck permissions before performing it.

Right-click main grid headers to open column actions:

  • Sort ascending
  • Sort descending
  • Filter
  • Hide column
  • Columns

Visibility follows the active column:

  • Sort actions appear only when the target column has sortable: true.
  • Filter appears only when the target column has filter configured.
  • Hide column is available for a leaf task-table column; Columns opens the standard column-management dialog.
  • If contextual filtering leaves no visible items, the menu is not opened.

Sort, filtering, hiding, and column management reuse the shared RevoGrid data-grid context-menu commands. Gantt removes incompatible generic commands such as row mutation, formatting, pinning, and schema operations.

Right-click the pinned Gantt timeline/canvas header to open timeline actions:

  • Zoom
  • Date range
  • Show today
  • Show flags when milestone lines are configured

Zoom controls are hidden when the current zoom level cannot move further in either direction. Date range changes the visible timeline range; the visual toggles remain open after changing their checked state.

The row menu respects packaged Gantt protection state:

  • gantt.readOnly: true hides mutating row actions.
  • Selected locked tasks hide hierarchy actions.
  • Mutation services still guard direct calls, so blocked task operations return readonly-task.

Use the normal RevoGrid Pro menu config surfaces. Gantt keeps your custom items and contributes its generated items without mutating those configurations.

grid.rowContextMenu = {
items: [
{
name: 'Open task details',
action: (_event, focused, _range, _close, context) => {
const task = context?.providers.data.getModel?.(
focused?.y ?? 0,
'rgRow',
);
openTaskDetails(task?.id);
},
},
],
};

Gantt context menu customization has two layers:

  • gantt.contextMenu = false disables all context menus on the Gantt grid.
  • The row and column options disable generated actions for individual surfaces while allowing application items.
  • rowContextMenu and columnContextMenu hold application menu configuration.

Disable both generated surfaces when the application should fully own the menu:

grid.rowContextMenu = {
items: [
{
name: 'Open planning panel',
action: (_event, focused, _range, close, context) => {
const task = context?.providers.data.getModel?.(
focused?.y ?? 0,
'rgRow',
);
openPlanningPanel(task?.id);
close();
},
},
],
};
grid.gantt = {
...project,
contextMenu: { row: false, column: false },
};

Use partial opt-out when you want custom row actions but still want generated column and timeline actions:

grid.rowContextMenu = {
items: [
{
name: 'Assign owner',
action: (_event, focused, _range, close, context) => {
const task = context?.providers.data.getModel?.(
focused?.y ?? 0,
'rgRow',
);
openOwnerPicker(task?.id);
close();
},
},
],
};
grid.gantt = {
...project,
contextMenu: {
row: false,
column: true,
},
};

Keep gantt.contextMenu enabled when you want to append app actions after the default Gantt actions:

grid.rowContextMenu = {
items: [
{
name: 'Show audit log',
action: (_event, focused, _range, close, context) => {
const task = context?.providers.data.getModel?.(
focused?.y ?? 0,
'rgRow',
);
showTaskAuditLog(task?.id);
close();
},
},
],
};
grid.gantt = project;

You can also use a resolve function on the base RevoGrid menu config. Gantt preserves the resolver and the context menu plugin applies it to the composed menu:

grid.rowContextMenu = {
items: [{ name: 'Open task details', action: openTaskDetailsFromMenu }],
resolve(context) {
return context.target === 'row' ? undefined : null;
},
};

The packaged task editor item is controlled separately:

grid.ganttTaskEditorDialog = {
contextMenu: false,
};

Set ganttTaskEditorDialog.contextMenu to true to include the default Edit… item when menus are enabled. The global gantt.contextMenu = false setting suppresses it along with all other menu items.

For packaged extension items, use the built-in Gantt context-menu helpers:

import { createGanttContextMenuExtensionItems } from '@revolist/gantt';
const customItems = createGanttContextMenuExtensionItems({
duplicate: {
copyName: (task) => `${task.name ?? 'Task'} copy`,
},
assignResource: {
onAssignResource: (context) => {
if (context.taskId) {
openResourcePicker(context.taskId);
}
},
},
delete: false,
export: { name: 'Export task rows' },
});
grid.rowContextMenu = {
...grid.rowContextMenu,
items: [...(grid.rowContextMenu?.items ?? []), ...customItems],
};

rowContextMenu and columnContextMenu remain application-owned low-level menu configuration. Use dataGridContextMenu.getItems when you need to transform the Gantt-compatible shared grid commands: registered Gantt contributions run first, then this application resolver receives the filtered items.

Gantt registers and disposes its own contribution with the plugin lifecycle. It does not rewrite host menu properties, so application-provided items are not duplicated during Gantt configuration updates.

The packaged task editor follows gantt.contextMenu by default for its Edit… row-menu item. Set ganttTaskEditorDialog.contextMenu to false to disable only the editor item, or true to keep the editor item when generated Gantt menus are disabled.