Skip to content

Row Selection

Select task rows with the left checkboxes, then compare single-task and multi-task hierarchy actions. The pinned add-task draft has no task-selection checkbox.

Source code
src/components/gantt/gantt-showcase/GanttShowcase.ts
import '@revolist/ui/styles.scss';
import { createControl } from '@revolist/ui';
import './gantt-showcase.scss';
import { defineCustomElements } from '@revolist/revogrid/loader';
defineCustomElements();
import { GanttPlugin } from '@revolist/gantt';
import { ExportExcelPlugin, RowStatusPlugin } from '@revolist/revogrid-pro';
import {
STANDARD_CALENDAR,
SHOWCASE_ASSIGNMENTS,
SHOWCASE_BASELINES,
SHOWCASE_COLUMNS_WITH_COMPLETION,
SHOWCASE_DEFAULT_HIDDEN,
SHOWCASE_DEPENDENCIES,
SHOWCASE_GANTT_CONFIG,
SHOWCASE_RESOURCES,
SHOWCASE_TASKS,
renderShowcaseTaskBarColor,
renderShowcaseTaskBarContent,
} from '../shared/gantt-project-data';
import { currentTheme } from '../../composables/useRandomData';
// ─── Entry point ──────────────────────────────────────────────────────────────
export function load(parentSelector: string): void {
const parent = document.querySelector(parentSelector);
if (!parent) return;
const darkTheme = currentTheme().isDark();
const container = document.createElement('div');
container.className = `gantt-showcase-shell grow h-full ${darkTheme ? 'gantt-showcase-shell--dark' : 'gantt-showcase-shell--light'}`;
parent.appendChild(container);
const grid = document.createElement('revo-grid') as HTMLRevoGridElement;
const controls = document.createElement('div');
controls.className = 'gantt-showcase-controls';
container.appendChild(controls);
grid.theme = darkTheme ? 'darkCompact' : 'compact';
grid.readonly = false;
grid.range = true;
grid.resize = true;
grid.rowSize = 42;
grid.rowHeaders = false;
grid.hideAttribution = true;
grid.autoSizeColumn = false;
grid.classList.add('gantt-showcase-grid');
grid.plugins = [GanttPlugin, ExportExcelPlugin, RowStatusPlugin];
grid.hideColumns = [...SHOWCASE_DEFAULT_HIDDEN];
grid.columns = [...SHOWCASE_COLUMNS_WITH_COMPLETION];
grid.source = [...SHOWCASE_TASKS];
grid.ganttDependencies = [...SHOWCASE_DEPENDENCIES];
grid.ganttCalendars = [{ ...STANDARD_CALENDAR }];
grid.ganttResources = [...SHOWCASE_RESOURCES];
grid.ganttAssignments = [...SHOWCASE_ASSIGNMENTS];
grid.ganttBaselines = [...SHOWCASE_BASELINES];
let showCriticalPath = Boolean(
SHOWCASE_GANTT_CONFIG.visuals.showCriticalPath,
);
let showBaseline = false;
function applyGanttConfig() {
grid.gantt = {
...SHOWCASE_GANTT_CONFIG,
visuals: {
...SHOWCASE_GANTT_CONFIG.visuals,
showCriticalPath,
showBaseline,
taskBarColorHook: renderShowcaseTaskBarColor,
taskBarContentHook: renderShowcaseTaskBarContent,
},
} as typeof grid.gantt;
}
function createToggle(
label: string,
checked: () => boolean,
onChange: (value: boolean) => void,
) {
const control = createControl(document, 'button', { class: 'rv-btn-sm' });
control.textContent = label;
const sync = () => {
control.setAttribute('aria-pressed', String(checked()));
control.classList.toggle('rv-btn-primary', checked());
};
control.addEventListener('click', () => {
onChange(!checked());
applyGanttConfig();
sync();
});
sync();
return control;
}
controls.append(
createToggle(
'Critical path',
() => showCriticalPath,
(value) => {
showCriticalPath = value;
},
),
createToggle(
'Baselines',
() => showBaseline,
(value) => {
showBaseline = value;
},
),
);
applyGanttConfig();
container.appendChild(grid);
}

GanttPlugin can work with the RevoGrid Pro RowSelectPlugin when you want checkbox-based task selection in the task table.

Add a row-select column, register RowSelectPlugin, and enable the row-order bridge when selected rows should move together during Gantt row reordering.

import { GanttPlugin, isGanttAddTaskRow } from '@revolist/gantt';
import { RowSelectPlugin } from '@revolist/revogrid-pro';
const grid = document.querySelector('revo-grid');
grid.plugins = [GanttPlugin, RowSelectPlugin];
grid.rowSelect = {
rowOrder: true,
};
grid.columns = [
{
prop: 'selected',
name: '',
rowSelect: ({ model }) => !isGanttAddTaskRow(model),
size: 56,
readonly: true,
filter: false,
},
// Task table columns...
];

The checkbox column uses physical task rows from grid.source. Gantt ignores resource rows and non-task rows when resolving checkbox selection for task operations.

Use isGanttAddTaskRow() when taskCreateRow is enabled so the pinned “Add new task” row does not render a checkbox. See Add Task Row for the draft-row contract.

When no explicit task ids are passed, Gantt resolves task ids in this order:

  1. Checkbox-selected rows from RowSelectPlugin.
  2. Gantt task range selection.
  3. The currently focused or selected Gantt task.

This means toolbar buttons, context-menu actions, keyboard handlers, or application code can call the existing Gantt methods without manually collecting checkbox state:

const plugins = await grid.getPlugins();
const gantt = plugins.find((plugin) => plugin instanceof GanttPlugin);
gantt?.deleteTasks();
gantt?.indentTasks();
gantt?.outdentTasks();
gantt?.convertTasksToMilestones();

After a successful delete, Gantt clears the row-select checkbox state for task rows so removed tasks do not remain selected in RowSelectPlugin.

Gantt installs RowOrderPlugin internally. RowSelectPlugin does not automatically move all checked rows unless the row-select row-order integration is enabled:

grid.rowSelect = {
rowOrder: true,
};

With rowOrder: true, dragging a checked task row moves the visible checked task rows as one compact block. Dragging an unchecked row keeps the normal Gantt row-order behavior.

<RevoGrid
plugins={[GanttPlugin, RowSelectPlugin]}
rowSelect={{ rowOrder: true }}
columns={[
{
prop: 'selected',
name: '',
rowSelect: ({ model }) => !isGanttAddTaskRow(model),
size: 56,
readonly: true,
filter: false,
},
...taskColumns,
]}
/>

For Vue Gantt examples, use .prop for row-select because it is a direct grid plugin property.