Skip to content

Editing, Validation, Diagnostics

Try moving Visual Design into the April 14–18 freeze window: the before-change handler rejects the move. Inspect the validation result and protected-row indicators, then open the Task Editing guide for the custom editor.

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();
};
}

These APIs are presentation-free. They make decisions and shape data, while your application owns forms, popovers, panels, toasts, and persistence.

The application recipes below live in the examples source browser. Copy their recipes/ files beside your code before using the relative imports; they are maintained examples rather than published Gantt exports.

import {
GANTT_BEFORE_ASSIGNMENT_CHANGE_EVENT,
GANTT_BEFORE_DEPENDENCY_CHANGE_EVENT,
GANTT_BEFORE_TASK_CHANGE_EVENT,
TASK_EDITOR_FIELD_SCHEMA,
buildDependencyValidationSummary,
buildResourceOverallocationSummary,
createGanttRoleEditabilityHelpers,
createTaskDetailPopoverModel,
createTaskEditorFormValues,
normalizeTaskEditorSubmit,
} from '@revolist/gantt';
import {
createApprovalGateValidator,
createForbiddenDateRangeValidator,
createGanttBeforeTaskChangeValidationHandler,
createLockedPhaseValidator,
createRoleGuardValidator,
} from './recipes/validation-recipes';

Before-change events are cancelable. Use role helpers to decide whether a task, dependency, or assignment mutation should proceed. Call event.preventDefault() to stop the packaged mutation before the Gantt store changes; timeline previews are cleared and the next render keeps the previous task, dependency, or assignment data.

const policy = {
roles: {
viewer: [],
planner: ['task:*', 'dependency:create', 'dependency:delete'],
staffing: ['assignment:edit'],
admin: ['*'],
},
fallback: 'deny',
} as const;
const editability = createGanttRoleEditabilityHelpers(policy);
const getRoleContext = () => ({ roles: currentUser.roles });
grid.addEventListener(GANTT_BEFORE_TASK_CHANGE_EVENT, (event) => {
if (!editability.canEditTask(event.detail, getRoleContext())) {
event.preventDefault();
}
});
grid.addEventListener(GANTT_BEFORE_DEPENDENCY_CHANGE_EVENT, (event) => {
if (!editability.canEditDependency(event.detail, getRoleContext())) {
event.preventDefault();
}
});
grid.addEventListener(GANTT_BEFORE_ASSIGNMENT_CHANGE_EVENT, (event) => {
if (!editability.canEditAssignment(event.detail, getRoleContext())) {
event.preventDefault();
}
});

Task before-change actions cover move, resize, create, edit, progress, split, indent, outdent, and delete. Dependency before-change actions cover create, delete, edit, and replace; replace is emitted by predecessor/successor inline field edits and includes previousDependencies plus proposed dependencies because one cell edit can add, update, and remove multiple links. Assignment edits emit proposed assignments and previousAssignments.

For task edits, event.detail.sourcePatch contains the flat source-row fields that the packaged Gantt store will write. Use it when persisting custom row fields or when your backend uses public source names such as duration, percentDone, and taskMode.

grid.addEventListener(GANTT_BEFORE_TASK_CHANGE_EVENT, (event) => {
const { sourceIndex, sourcePatch, previousSourceValues } = event.detail;
if (sourceIndex === undefined || !sourcePatch) {
return;
}
queueTaskRowPersistence({
rowIndex: sourceIndex,
patch: sourcePatch,
previousValues: previousSourceValues ?? {},
});
});

Use the field schema and initial value builder to render a framework form, then normalize submitted values into a TaskUpdate patch.

For a complete standalone UI example, see Task Editing.

const fields = TASK_EDITOR_FIELD_SCHEMA.filter((field) =>
[
'name',
'startDate',
'endDate',
'progressPercent',
'resourceLabels',
].includes(field.id),
);
const values = createTaskEditorFormValues(task, resources, assignments);
renderTaskEditor({
fields,
values,
onSubmit(nextValues) {
const result = normalizeTaskEditorSubmit(task, nextValues);
if (!result.ok) {
renderErrors(result.errors);
return;
}
updateTask(task.id, result.patch);
},
});

createTaskDetailPopoverModel() returns sections, fields, warnings, and resource labels. Your app handles hover/focus, positioning, and rendering.

const model = createTaskDetailPopoverModel({
row,
task,
resources,
assignments,
});
renderPopover({
title: model.title,
subtitle: model.subtitle,
sections: model.sections,
resources: model.resourceAssignments.map(
(assignment) => assignment.displayValue,
),
});

Use dependency summaries to power badges, side panels, or task focus commands.

const summary = buildDependencyValidationSummary({
conflicts: schedulerResult.conflicts,
issues: schedulerResult.issues,
rows: projectedRows,
});
renderDiagnosticsPanel({
count: summary.totalCount,
groups: summary.groups,
});

Use resource summaries when staffing dashboards need to show who is overloaded and when.

const overloads = buildResourceOverallocationSummary({
rows: resourcePlanningRows,
loadSummaries: resourceLoadSummaries,
conflicts: schedulerResult.conflicts,
});
renderResourceHealth({
count: overloads.totalCount,
peakOverloadUnits: overloads.peakOverloadUnits,
groups: overloads.groups,
});

Compose validators and attach the generated handler to gantt-before-task-change.

const validators = [
createRoleGuardValidator({ policy }),
createForbiddenDateRangeValidator({
ranges: [
{
startDate: '2026-05-20',
endDate: '2026-05-27',
label: 'release freeze',
},
],
}),
createLockedPhaseValidator({
lockedPhaseIds: ['closed'],
getPhaseId: (detail) =>
detail.taskId ? phaseByTaskId[detail.taskId] : null,
}),
createApprovalGateValidator({
actions: ['move', 'resize', 'progress'],
requiresApproval: (detail) => detail.changes.progressPercent === 100,
}),
];
grid.addEventListener(
GANTT_BEFORE_TASK_CHANGE_EVENT,
createGanttBeforeTaskChangeValidationHandler({
context: () => validationContext,
validators,
onReject: ({ decision }) =>
showValidationToast(decision.message ?? 'Change rejected'),
}),
);