Syncfusion React Gantt Chart
The Syncfusion React Gantt Chart (GanttComponent) is a powerful project management component for visualizing, scheduling, and managing tasks over a timeline. It supports auto/manual scheduling, task dependencies, resource planning, interactive editing, Excel/PDF export, and rich customization.
When to Use This Skill
- Implementing a Gantt chart or project timeline in a React app
- Configuring task scheduling (auto, manual, custom modes)
- Setting up task dependencies (FS, SS, FF, SF) and constraints (ASAP, MSO, FNET, etc.)
- Binding local or remote data to the Gantt (local array, DataManager, UrlAdaptor, Ajax)
- Customizing taskbars, labels, milestones, and baselines
- Configuring resources and resource views (including multi-taskbar)
- Enabling editing (dialog, cell, taskbar drag) with validation rules
- Setting up column resize, reorder, freeze, or column menu
- Configuring WBS codes, tree column icons, or serial number columns
- Setting up filtering, sorting, or selection
- Scrolling to specific dates or controlling scroll position programmatically
- Exporting Gantt to Excel or PDF
- Handling Gantt events and enabling advanced features (undo/redo, virtual scroll, critical path, etc.)
- Globalization, localization, and RTL support
Documentation and Navigation Guide
Getting Started
📄 Read: references/getting-started.md
- Installation and package dependencies
- Vite / CRA project setup
- Theme package installation and CSS import via npm theme packages
- Basic
GanttComponent with taskFields mapping
- Module injection guide (all available services)
gridLines prop ('Both' / 'Horizontal' / 'Vertical' / 'None')
- First render walkthrough with minimal example, output summary, and common gotchas
Data Binding
📄 Read: references/data-binding.md
- Local array data binding
- Remote / AJAX data binding with
DataManager
- Self-referential flat data
taskFields configuration (id, name, startDate, endDate, duration, progress, child)
- Custom field mapping
- UrlAdaptor for server-side CRUD (
url + batchUrl)
- RemoteSaveAdaptor for local rendering with server persistence
- Sending additional parameters to server via
Query.addParams() in load event
- Binding with
Ajax class (manual fetch)
- Load child on demand (
loadChildOnDemand={false}, hasChildMapping)
- Handling HTTP errors with
actionFailure event
Task Scheduling
📄 Read: references/task-scheduling.md
- Auto, Manual, and Custom scheduling modes (
taskMode)
- Unscheduled tasks (duration-only, date-only, none)
- Project start date and end date configuration
- How scheduling mode affects parent task calculation
- Switching between modes dynamically
Task Dependency
📄 Read: references/task-dependency.md
- Dependency types: Finish-to-Start (FS), Start-to-Start (SS), Finish-to-Finish (FF), Start-to-Finish (SF)
- Mapping
taskFields.dependency in data source (string format: "2FS", "2FS+3d", "2SS+2h")
- Multiple predecessors per task (comma-separated:
"2FS,3FS")
- Offset values with units: day, hour, minute (e.g.,
"2FS+3h", "2FS-1d")
- Drawing dependencies via UI (drag from taskbar connection points)
- Programmatic dependency management (
addPredecessor, removePredecessor, updatePredecessor)
- Connector line customization (
connectorLineWidth, connectorLineBackground)
- Predecessor Offset Synchronization
autoUpdatePredecessorOffset={true} — recalculate offsets on load to account for calendar rules (weekends, holidays)
autoUpdatePredecessorOffset={false} — display original offsets even if not matching rendered lines (visual inconsistency possible)
- Offset Updates During Editing
updateOffsetOnTaskbarEdit={true} — auto-recalculate offsets when dragging taskbars (default)
updateOffsetOnTaskbarEdit={false} — preserve offsets; manual update required via dependency dialog
- Dependency Validation Modes (in
actionBegin event with requestType === 'validateLinkedTask')
respectLink={true} — revert invalid edits to maintain dependency integrity
removeLink={true} — remove conflicting dependencies to allow edits
preserveLinkWithEditing={true} — update offsets to maintain links (default mode)
- Validation Dialog — disable all modes to show user-choice dialog (cancel edit, remove link, adjust offset)
- Parent Dependencies —
allowParentDependency={true} allows cross-parent dependencies; false restricts to siblings only
- Show/Hide Dependencies Dynamically — toggle
.e-gantt-dependency-view-container CSS visibility
- Disable Validation —
enablePredecessorValidation={false} disables auto-date validation based on predecessor links
Task Constraints
📄 Read: references/task-constraints.md
- Eight constraint types: ASAP, ALAP, MSO, MFO, SNET, SNLT, FNET, FNLT
- Mapping
taskFields.constraintType and taskFields.constraintDate
- How constraints interact with dependencies and
taskMode
- Editing constraints via dialog
- Validation and conflict handling
Timeline and Zooming
📄 Read: references/timeline.md
timelineViewMode quick presets (Hour, Day, Week, Month, Year)
- Top tier and bottom tier independent configuration (
unit, format, count, formatter)
- Combining timeline cells using
count (merge multiple units per cell)
- Custom timeline cell formatting using
formatter (tier + mode aware)
- Timeline view dates with
viewStartDate / viewEndDate (lock visible range)
weekStartDay — controls which day starts a week column (0=Sun, 1=Mon…)
- Automatic timescale updates using
updateTimescaleView
- Dynamic timeline mode change at runtime (update
timelineViewMode + refresh())
- Timeline cell tooltip visibility using
showTooltip
- Timeline template customization using
timelineTemplate ({ date, value, tier })
- Infinite timeline scrolling using
enableInfiniteTimelineScroll (extends the visible range while navigating with horizontal scrollbar or scroll arrows)
- Timeline navigation using
previousTimeSpan() / nextTimeSpan()
- Zooming with toolbar (
ZoomIn, ZoomOut, ZoomToFit)
- Customizing zoom steps with
zoomingLevels (ZoomTimelineSettings)
- Programmatic zoom methods:
zoomIn(), zoomOut(), fitToProject()
- Timeline cell width using
timelineUnitSize
- Weekend handling:
- Highlight weekends with
highlightWeekends={true}
- Hide weekends using
timelineSettings.showWeekend (with noted limitations)
Columns
📄 Read: references/columns.md
- Column types overview (tree column, WBS, custom columns)
- Auto-generated columns (omit
ColumnsDirective)
- Column rendering with
valueAccessor (custom display values, concatenation)
- Expression columns (calculated values via
valueAccessor)
- Display serial numbers via
rowDataBound
- Tree column configuration (
treeColumnIndex)
- Customize expand/collapse icons (CSS override)
- Customize indentation via
queryCellInfo
collapseAllParentTasks — collapse all on load
taskFields.expandState — per-row initial expand/collapse
- Persist expand/collapse state in
localStorage
- WBS (Work Breakdown Structure) column
enableWBS + enableAutoWbsUpdate APIs
- Manual WBS with
taskFields.wbsPredecessor
- Column headers, format, and alignment
headerTemplate for custom header rendering
- Header text wrapping (
treeGrid.textWrapSettings.wrapMode)
- Dynamic header text update (
getColumnByField + refreshHeader)
- Column templates (custom cell rendering) and
editTemplate
- Column spanning and frozen columns (
frozenColumns, inject Freeze)
Column Interactions
📄 Read: references/column-interactions.md
- Column resizing (
allowResizing, inject Resize)
- Restrict with
minWidth / maxWidth per column
- Prevent resize per column (
allowResizing={false})
- Resize modes: Normal vs Auto (
resizeSettings.mode)
- Programmatic resize (
reorderColumns, refreshColumns)
- Resize events:
resizeStart, resizing, resizeStop
- Column reorder (
allowReordering, inject Reorder)
- Disable reorder per column (
allowReordering={false})
- Programmatic reorder:
reorderColumns, reorderColumnByIndex, reorderColumnByTargetIndex
- Reorder drag events:
columnDragStart, columnDrag, columnDrop
- Column menu (
showColumnMenu, inject ColumnMenu)
- Built-in items: SortAscending, SortDescending, AutoFit, AutoFitAll, ColumnChooser, Filter
- Custom column menu items +
columnMenuClick event
- Disable per column (
showColumnMenu={false})
- Toggling column visibility (show/hide columns)
Rows
📄 Read: references/rows.md
- Row drag-and-drop (reorder and reparent tasks)
- Indent and outdent (change task hierarchy)
- Row spanning via
queryCellInfo event
QueryCellInfoEventArgs with rowSpan, colSpan, cell, data, column
- Horizontal spanning (
colSpan) and vertical spanning (rowSpan)
- Row height configuration
- Row styling via
rowDataBound
- Expand and collapse rows programmatically
Managing Tasks
📄 Read: references/managing-tasks.md
- Adding new tasks (toolbar, context menu, programmatic
addRecord())
- Editing tasks — dialog edit (
mode: 'Dialog'), cell edit (mode: 'Auto'), taskbar drag
- Deleting tasks (toolbar,
deleteRecord(), showDeleteConfirmDialog)
- Taskbar drag editing: move, resize right edge, progress handle, dependency drawing
- Splitting and merging tasks (
taskFields.segments, splitTask(), mergeTask())
- Cell edit types (
editType): stringedit, numericedit, datepickeredit, datetimepickeredit, dropdownedit, booleanedit
edit.params for min/max/step/format/dataSource per column
- Customizing add/edit dialog fields (
addDialogFields, editDialogFields)
- Server-side CRUD with
UrlAdaptor (url + batchUrl)
- Server receives
added, changed, deleted arrays in the batch request body
- Column-level validation rules (
validationRules on ColumnDirective)
- Built-in rules:
required, min, max, minLength, date, regex
- Custom validator functions (
[fn, 'message'] callback pattern)
Filtering and Searching
📄 Read: references/filtering-searching.md
- Basic column filtering (
allowFiltering={true}, inject Filter)
- Filter hierarchy modes:
Parent, Child, Both, None
- Filter menu (string, number, date operators) and Excel-like checklist filter
- Toolbar search box (
searchSettings: fields, operator, ignoreCase)
- Initial filter state on load (
filterSettings.columns array)
- Programmatic filter API:
filterByColumn(), clearFiltering()
- Custom multi-column filter predicates
Sorting
📄 Read: references/sorting.md
- Single-column and multi-column sorting
- Initial sort state (
sortSettings)
- Custom sort comparers
- Programmatic sorting API
Selection
📄 Read: references/selection.md
- Row selection modes (single, multiple)
- Cell selection
- Keyboard-based selection
- Programmatic selection API (
selectRow, selectCell)
Taskbar, Labels, and Markers
📄 Read: references/taskbar-labels-markers.md
- Taskbar template (custom rendering)
- Parent taskbar and milestone customization
- Tooltip settings and templates (
tooltipSettings for taskbar, connector line, baseline, timeline)
- Disable/hide tooltips for specific UI targets using
beforeTooltipRender
- Left, right, and task label configuration
- Data markers / indicators
- Event markers (deadlines, holidays on timeline)
- Baseline rendering
- Baseline template customization using
baselineTemplate
- Critical path highlighting
Resources
📄 Read: references/resources.md
- Defining resource collection (
resources property)
- Assigning resources to tasks (
taskFields.resourceInfo) — single or multiple with custom units
- Resource view layout (
viewType='ResourceView', resource groups)
- Multi-taskbar (
enableMultiTaskbar={true}) — multiple taskbars per collapsed resource row
- Over-allocation highlighting (
showOverAllocatedTasks={true})
- Resource unit and work fields (
resourceFields.unit, resourceFields.group)
- Custom resource taskbar styling via
queryTaskbarInfo
Toolbar
📄 Read: references/toolbar-context-menu.md
- Built-in toolbar items:
Add, Edit, Delete, Update, Cancel, Search, ExpandAll, CollapseAll, Indent, Outdent, PrevTimeSpan, NextTimeSpan, ZoomIn, ZoomOut, ZoomToFit, CriticalPath, ExcelExport, CsvExport, PdfExport, ColumnChooser, Undo, Redo, SplitTask, MergeTask
- Required services:
Undo/Redo → UndoRedo; SplitTask/MergeTask → Edit; CriticalPath → CriticalPath; ExcelExport/CsvExport → ExcelExport; PdfExport → PdfExport; ColumnChooser → ColumnMenu
- Custom toolbar buttons using
ItemModel; handle clicks via toolbarClick event (args.item.id)
- Enable/disable toolbar items programmatically via
enableItems()
Context Menu
📄 Read: references/toolbar-context-menu.md
- Enable with
enableContextMenu={true}; inject ContextMenu service
- Default context menu items:
AutoFit, AutoFitAll, SortAscending, SortDescending, TaskInformation, Add, Indent, Outdent, DeleteTask, Save, Cancel, DeleteDependency, Convert, SplitTask, MergeTask
- Custom context menu items using
contextMenuItems array with target (.e-content or .e-gridheader)
- Handle clicks via
contextMenuClick event; control visibility via contextMenuOpen (args.hideItems)
Excel Export
📄 Read: references/excel-export.md
- Basic Excel export
- Export properties and customization
- Exporting multiple Gantt charts to a single Excel workbook
- Custom data source export
PDF Export
📄 Read: references/pdf-export.md
- Basic PDF export
- Customizing PDF (fonts, columns, styles)
- Header and footer configuration
- Page settings (orientation, size)
Holidays, Working Time & Timezone
📄 Read: references/holidays-working-time.md
- Defining holidays (
holidays prop, HolidayModel, DayMarkers service)
- Work week configuration (
workWeek, includeWeekend)
- Daily working time (
dayWorkingTime)
- Effort-based scheduling (
taskFields.work, workUnit, task types: FixedWork / FixedDuration / FixedUnit)
- Timezone support (
timezone prop, IANA timezone strings)
Splitter
📄 Read: references/splitter.md
- Position-based split (
splitterSettings.position — percentage or pixels)
- Column-based split (
splitterSettings.columnIndex)
- View mode (
splitterSettings.view — Default / Grid / Chart)
- Programmatic resize (
setSplitterPosition())
- Splitter events (
splitterResizeStart, splitterResizing, splitterResized)
Scrolling
📄 Read: references/scrolling.md
- Setting
width and height for scrollbar control
- Responsive container (
width='100%', height='100%' with CSS parent height)
- Scroll to a date (
scrollToDate('MM/dd/yyyy'))
- Set vertical scroll position (
ganttChartModule.scrollObject.setScrollTop(px))
Virtual Scroll
📄 Read: references/virtual-scroll.md
- Row virtualization (
enableVirtualization={true}, VirtualScroll service)
- Timeline virtualization (
enableTimelineVirtualization={true}, requires projectStartDate / projectEndDate)
- Combining row + timeline virtualization
- Accessing filtered record count with virtual scroll (
treeGrid.filterModule.filteredResult)
- Virtual scroll limitations (browser memory, cell selection, pixel height, expand state)
Undo / Redo
📄 Read: references/undo-redo.md
- Enable undo/redo (
enableUndoRedo, UndoRedo service)
undoRedoActions — full list of trackable actions and required services
undoRedoStepsCount — history stack size
- Toolbar
'Undo' / 'Redo' buttons and Ctrl+Z / Ctrl+Y keyboard shortcuts
- Programmatic
undo() / redo() via component ref
State Persistence, Immutable Mode & Loading
📄 Read: references/state-persistence.md
- State persistence (
enablePersistence={true}, unique id prop, localStorage)
- Resetting persisted state (change
id or clear localStorage entry)
- Immutable mode (
enableImmutableMode={true}, requires isPrimaryKey={true})
- Loading animation (
loadingIndicator.indicatorType: 'Spinner' or 'Shimmer')
- Manual spinner control (
showSpinner() / hideSpinner())
Localization and RTL
📄 Read: references/localization-rtl.md
- Setting locale (
locale prop)
- Loading custom translations (
L10n.load() with 'gantt' namespace keys)
- Gantt locale key reference (all translatable UI strings)
- RTL support (
enableRtl={true})
- Column date formatting (
format='yMd', format='dd/MM/yyyy')
- Column number formatting (
format='C2', format='N2', format='P0')
Programmatic Methods
📄 Read: references/gantt-methods.md
- Column utilities:
autoFitColumns()
- Edit control:
cancelEdit(), openAddDialog(), openEditDialog()
- Task management:
deleteRecord(), convertToMilestone(), changeTaskMode(), updateRecordByID(), updateRecordByIndex(), updateTaskId(), updateDataSource(), updateProjectDates()
- Toolbar control:
enableItems()
- Expand/Collapse:
expandByID(), expandByIndex(), collapseByID(), collapseByIndex()
- Undo/Redo stacks:
clearUndoCollection(), clearRedoCollection(), getUndoActions(), getRedoActions()
- Data retrieval:
getCurrentViewData(), getRecordByID(), getTaskByUniqueID(), getTaskInfo(), getTaskbarHeight(), getExpandedRecords(), getGanttColumns(), getGridColumns()
- Formatting helpers:
getDurationString(), getWorkString()
- DOM access:
getRowByID(), getRowByIndex()
- Sorting:
removeSortColumn()
- Selection:
selectCells()
- Row reorder:
reorderRows()
- Scrolling:
scrollToTask(), updateChartScrollOffset()
Events
📄 Read: references/events.md
- Lifecycle events (
load, created, dataBound)
- Task editing events (
actionBegin, actionComplete) with requestType reference table
- Taskbar events:
taskbarEditing, taskbarEdited, taskbarClick
- Row expand/collapse events:
expanding, collapsing, expanded, collapsed
- Selection events:
rowSelected, rowDeselected, cellSelected, cellDeselected
- Export events:
excelExportComplete, pdfExportComplete
- Column interaction events:
resizeStart, resizing, resizeStop, columnDragStart, columnDrag, columnDrop
- Event cancellation patterns (
args.cancel = true)
- Complete all-events quick reference table (30+ events)
Quick Start Example
import * as React from 'react';
import { GanttComponent, ColumnsDirective, ColumnDirective, Inject, Edit, Toolbar, Selection } from '@syncfusion/ej2-react-gantt';
import { TaskFieldsModel, EditSettingsModel } from '@syncfusion/ej2-gantt';
import './App.css';
// In App.css:
// @import "../node_modules/@syncfusion/ej2-tailwind3-theme/styles/gantt/index.css";
const data = [
{
TaskID: 1, TaskName: 'Project Initiation',
StartDate: new Date('04/02/2024'), EndDate: new Date('04/21/2024'),
subtasks: [
{ TaskID: 2, TaskName: 'Identify Site Location', StartDate: new Date('04/02/2024'), Duration: 4, Progress: 50 },
{ TaskID: 3, TaskName: 'Perform Soil Test', StartDate: new Date('04/02/2024'), Duration: 4, Progress: 50, Predecessor: '2' },
{ TaskID: 4, TaskName: 'Soil Test Approval', StartDate: new Date('04/08/2024'), Duration: 0, Predecessor: '3FS', Progress: 50 },
]
}
];
const taskFields: TaskFieldsModel = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
dependency: 'Predecessor',
child: 'subtasks',
};
const editSettings: EditSettingsModel = { allowEditing: true, allowAdding: true, allowDeleting: true, allowTaskbarEditing: true };
function App() {
return (
<GanttComponent
dataSource={data}
taskFields={taskFields}
editSettings={editSettings}
toolbar={['Add', 'Edit', 'Delete', 'Cancel', 'Update', 'Search', 'ZoomIn', 'ZoomOut', 'ZoomToFit']}
height="450px"
>
<ColumnsDirective>
<ColumnDirective field="TaskID" width="80" />
<ColumnDirective field="TaskName" headerText="Task Name" width="250" />
<ColumnDirective field="StartDate" />
<ColumnDirective field="Duration" />
<ColumnDirective field="Progress" />
</ColumnsDirective>
<Inject services={[Edit, Toolbar, Selection]} />
</GanttComponent>
);
}
export default App;
Common Patterns
Enable Editing with Dialog
<GanttComponent
editSettings={{ allowEditing: true, mode: 'Dialog' }}
>
<Inject services={[Edit]} />
</GanttComponent>
Enable Cell Editing
<GanttComponent
editSettings={{ allowEditing: true, mode: 'Auto' }}
>
<Inject services={[Edit]} />
</GanttComponent>
Programmatically Add a Task
const ganttRef = React.useRef<GanttComponent>(null);
const addTask = () => {
ganttRef.current?.addRecord({ TaskID: 10, TaskName: 'New Task', Duration: 3 }, 'Below', 1);
};
Export to Excel
<GanttComponent toolbar={['ExcelExport']} allowExcelExport={true}>
<Inject services={[ExcelExport, Toolbar]} />
</GanttComponent>
Export to PDF
<GanttComponent toolbar={['PdfExport']} allowPdfExport={true}>
<Inject services={[PdfExport, Toolbar]} />
</GanttComponent>
Column-Level Validation Rules
<ColumnsDirective>
<ColumnDirective field="TaskName" validationRules={{ required: true }} />
<ColumnDirective field="Duration" validationRules={{ min: 1, max: 100 }} />
</ColumnsDirective>
Scroll to Date Programmatically
const ganttRef = React.useRef<GanttComponent>(null);
ganttRef.current?.scrollToDate('04/28/2024');
Column Resize with Min/Max Width
<ColumnDirective field="TaskName" minWidth="100" maxWidth="400" allowResizing={true} />
Reorder Columns Programmatically
const ganttRef = React.useRef<GanttComponent>(null);
// By field names:
(ganttRef.current as any).treeGrid.reorderColumns(['Duration', 'Progress'], 'TaskName');
// By index:
(ganttRef.current as any).treeGrid.reorderColumnByIndex(2, 0);
Persist Tree Expand/Collapse State
// In taskFields — map a boolean field that controls initial expand state:
const taskFields = { ..., expandState: 'isExpand' };
// Or collapse all on load:
<GanttComponent collapseAllParentTasks={true} .../>
Key Module Injections
| Feature |
Service to Inject |
| Editing (add/edit/delete/taskbar drag) |
Edit |
| Filtering |
Filter |
| Sorting |
Sort |
| Toolbar |
Toolbar |
| Selection |
Selection |
| Day Markers / Holidays / Event Markers |
DayMarkers |
| Critical Path |
CriticalPath |
| Excel / CSV Export |
ExcelExport |
| PDF Export |
PdfExport |
| Undo / Redo |
UndoRedo |
| Column Menu |
ColumnMenu |
| Context Menu |
ContextMenu |
| Virtual Scrolling |
VirtualScroll |
| Row Drag and Drop |
RowDD |
| Column Reordering |
Reorder |
| Frozen Columns |
Freeze |
| Column Resizing |
Resize |
Usage pattern:
import { GanttComponent, Inject, Edit, Filter, Sort, Toolbar, Selection } from '@syncfusion/ej2-react-gantt';
<GanttComponent ...>
<Inject services={[Edit, Filter, Sort, Toolbar, Selection]} />
</GanttComponent>
Key Props Reference
| Prop |
Type |
Purpose |
dataSource |
object[] / DataManager |
Task data (local or remote via DataManager) |
taskFields |
TaskFieldsModel |
Field mapping for task properties |
editSettings |
EditSettingsModel |
Enable add/edit/delete/taskbar editing |
toolbar |
string[] |
Toolbar items to render |
taskMode |
Auto / Manual / Custom |
Scheduling mode |
resources |
object[] |
Resource data collection |
resourceFields |
ResourceFieldsModel |
Resource field mapping |
allowSorting |
boolean |
Enable sorting |
allowFiltering |
boolean |
Enable filtering |
allowReordering |
boolean |
Enable column reorder |
allowResizing |
boolean |
Enable column resize |
allowExcelExport |
boolean |
Enable Excel export |
allowPdfExport |
boolean |
Enable PDF export |
undoRedoActions |
string[] |
Actions tracked by undo/redo |
timelineSettings |
TimelineSettingsModel |
Timeline tiers and unit config |
splitterSettings |
SplitterSettingsModel |
Grid/chart panel ratio |
highlightWeekends |
boolean |
Shade weekend columns |
holidays |
HolidayModel[] |
Mark holiday dates |
eventMarkers |
EventMarkerModel[] |
Vertical markers on timeline |
treeColumnIndex |
number |
Column index showing expand/collapse icons |
collapseAllParentTasks |
boolean |
Collapse all parent rows on initial load |
enableWBS |
boolean |
Auto-generate WBS codes from task hierarchy |
enableAutoWbsUpdate |
boolean |
Recalculate WBS codes after CRUD/sort/DnD |
frozenColumns |
number |
Number of left-pinned (frozen) columns |
enableMultiTaskbar |
boolean |
Show multiple taskbars per resource row |
allowTaskbarOverlap |
boolean |
Controls whether multiple taskbars overlap (true, default) or stack with extended row height (false) in resource rows |
viewType |
string |
'ProjectView' or 'ResourceView' |
showColumnMenu |
boolean |
Show column-level menu (sort, filter, autofit) |
columnMenuItems |
string[] |
Restrict which column menu items are shown |
showColumnChooser |
boolean |
Enable column chooser dialog via toolbar ColumnChooser item |
allowSelection |
boolean |
Enable row/cell selection |
selectionSettings |
SelectionSettingsModel |
Selection mode (Row/Cell), type (Single/Multiple) |
gridLines |
string |
Grid lines style: 'Both' | 'Horizontal' | 'Vertical' | 'None' |
renderBaseline |
boolean |
Show baseline bars alongside actual taskbars |
baselineColor |
string |
CSS color for baseline bars |
baselineTemplate |
function/string |
Custom baseline rendering for planned schedules and advanced baseline layouts |
enableInfiniteTimelineScroll |
boolean |
Enable infinite horizontal timeline scrolling by extending the visible range as the user navigates |
enableCriticalPath |
boolean |
Highlight critical path tasks and connectors |
enableRtl |
boolean |
Enable right-to-left layout |
locale |
string |
Locale code (e.g. 'fr', 'de', 'ar') |
allowRowDragAndDrop |
boolean |
Enable row drag-and-drop reordering/reparenting |
enableImmutableMode |
boolean |
Only re-render changed rows on data updates (requires isPrimaryKey) |
enablePersistence |
boolean |
Persist UI state (sort, filter, column widths) to localStorage |
loadingIndicator |
object |
Loading animation type: { indicatorType: 'Spinner' | 'Shimmer' } |
workWeek |
string[] |
Working days, e.g. ['Monday','Tuesday','Wednesday','Thursday','Friday'] |
includeWeekend |
boolean |
Count weekends as working days for duration calculation |
timezone |
string |
IANA timezone for the Gantt (e.g. 'America/New_York') |
showOverAllocatedTasks |
boolean |
Highlight over-allocated resources in ResourceView |
enableUndoRedo |
boolean |
Enable undo/redo tracking (inject UndoRedo service) |
undoRedoStepsCount |
number |
Maximum undo/redo history steps (default: 10) |
enableVirtualization |
boolean |
Row virtualization for large data sets |
enableTimelineVirtualization |
boolean |
Timeline (horizontal) virtualization |
rowHeight |
number |
Uniform row height in pixels |
taskbarHeight |
number |
Height of taskbars in pixels (must be ≤ rowHeight) |
connectorLineWidth |
number |
Width of dependency connector lines |
connectorLineBackground |
string |
Color of dependency connector lines |
1---2name: syncfusion-react-gantt-chart3description: Implement, configure, and customize the Syncfusion React Gantt Chart component. Use this when building project scheduling applications with task timelines, dependencies, and resource management. Covers GanttComponent setup, task constraints, taskbar customization, filtering, sorting, Excel/PDF export, critical path analysis, milestones, predecessors, resource view, and baseline tracking.4---5
6# Syncfusion React Gantt Chart
7
8The Syncfusion React Gantt Chart (`GanttComponent`) is a powerful project management component for visualizing, scheduling, and managing tasks over a timeline. It supports auto/manual scheduling, task dependencies, resource planning, interactive editing, Excel/PDF export, and rich customization.
9
10## When to Use This Skill
11
12- Implementing a Gantt chart or project timeline in a React app
13- Configuring task scheduling (auto, manual, custom modes)
14- Setting up task dependencies (FS, SS, FF, SF) and constraints (ASAP, MSO, FNET, etc.)
15- Binding local or remote data to the Gantt (local array, DataManager, UrlAdaptor, Ajax)
16- Customizing taskbars, labels, milestones, and baselines
17- Configuring resources and resource views (including multi-taskbar)
18- Enabling editing (dialog, cell, taskbar drag) with validation rules
19- Setting up column resize, reorder, freeze, or column menu
20- Configuring WBS codes, tree column icons, or serial number columns
21- Setting up filtering, sorting, or selection
22- Scrolling to specific dates or controlling scroll position programmatically
23- Exporting Gantt to Excel or PDF
24- Handling Gantt events and enabling advanced features (undo/redo, virtual scroll, critical path, etc.)
25- Globalization, localization, and RTL support
26
27---
28
29## Documentation and Navigation Guide
30
31### Getting Started
32📄 **Read:** [references/getting-started.md](references/getting-started.md)
33- Installation and package dependencies
34- Vite / CRA project setup
35- Theme package installation and CSS import via npm theme packages
36- Basic `GanttComponent` with `taskFields` mapping
37- Module injection guide (all available services)
38- `gridLines` prop (`'Both'` / `'Horizontal'` / `'Vertical'` / `'None'`)
39- First render walkthrough with minimal example, output summary, and common gotchas
40
41### Data Binding
42📄 **Read:** [references/data-binding.md](references/data-binding.md)
43- Local array data binding
44- Remote / AJAX data binding with `DataManager`
45- Self-referential flat data
46- `taskFields` configuration (id, name, startDate, endDate, duration, progress, child)
47- Custom field mapping
48- **UrlAdaptor** for server-side CRUD (`url` + `batchUrl`)
49- **RemoteSaveAdaptor** for local rendering with server persistence
50- Sending additional parameters to server via `Query.addParams()` in `load` event
51- Binding with `Ajax` class (manual fetch)
52- Load child on demand (`loadChildOnDemand={false}`, `hasChildMapping`)
53- Handling HTTP errors with `actionFailure` event
54
55### Task Scheduling
56📄 **Read:** [references/task-scheduling.md](references/task-scheduling.md)
57- Auto, Manual, and Custom scheduling modes (`taskMode`)
58- Unscheduled tasks (duration-only, date-only, none)
59- Project start date and end date configuration
60- How scheduling mode affects parent task calculation
61- Switching between modes dynamically
62
63### Task Dependency
64📄 **Read:** [references/task-dependency.md](references/task-dependency.md)
65- Dependency types: Finish-to-Start (FS), Start-to-Start (SS), Finish-to-Finish (FF), Start-to-Finish (SF)
66- Mapping `taskFields.dependency` in data source (string format: `"2FS"`, `"2FS+3d"`, `"2SS+2h"`)
67- Multiple predecessors per task (comma-separated: `"2FS,3FS"`)
68- Offset values with units: day, hour, minute (e.g., `"2FS+3h"`, `"2FS-1d"`)
69- Drawing dependencies via UI (drag from taskbar connection points)
70- Programmatic dependency management (`addPredecessor`, `removePredecessor`, `updatePredecessor`)
71- Connector line customization (`connectorLineWidth`, `connectorLineBackground`)
72- **Predecessor Offset Synchronization**
73 - `autoUpdatePredecessorOffset={true}` — recalculate offsets on load to account for calendar rules (weekends, holidays)
74 - `autoUpdatePredecessorOffset={false}` — display original offsets even if not matching rendered lines (visual inconsistency possible)
75- **Offset Updates During Editing**
76 - `updateOffsetOnTaskbarEdit={true}` — auto-recalculate offsets when dragging taskbars (default)
77 - `updateOffsetOnTaskbarEdit={false}` — preserve offsets; manual update required via dependency dialog
78- **Dependency Validation Modes** (in `actionBegin` event with `requestType === 'validateLinkedTask'`)
79 - `respectLink={true}` — revert invalid edits to maintain dependency integrity
80 - `removeLink={true}` — remove conflicting dependencies to allow edits
81 - `preserveLinkWithEditing={true}` — update offsets to maintain links (default mode)
82- **Validation Dialog** — disable all modes to show user-choice dialog (cancel edit, remove link, adjust offset)
83- **Parent Dependencies** — `allowParentDependency={true}` allows cross-parent dependencies; `false` restricts to siblings only
84- **Show/Hide Dependencies Dynamically** — toggle `.e-gantt-dependency-view-container` CSS visibility
85- **Disable Validation** — `enablePredecessorValidation={false}` disables auto-date validation based on predecessor links
86
87### Task Constraints
88📄 **Read:** [references/task-constraints.md](references/task-constraints.md)
89- Eight constraint types: ASAP, ALAP, MSO, MFO, SNET, SNLT, FNET, FNLT
90- Mapping `taskFields.constraintType` and `taskFields.constraintDate`
91- How constraints interact with dependencies and `taskMode`
92- Editing constraints via dialog
93- Validation and conflict handling
94
95### Timeline and Zooming
96📄 **Read:** [references/timeline.md](references/timeline.md)
97- `timelineViewMode` quick presets (`Hour`, `Day`, `Week`, `Month`, `Year`)
98- Top tier and bottom tier independent configuration (`unit`, `format`, `count`, `formatter`)
99- Combining timeline cells using `count` (merge multiple units per cell)
100- Custom timeline cell formatting using `formatter` (tier + mode aware)
101- Timeline view dates with `viewStartDate` / `viewEndDate` (lock visible range)
102- `weekStartDay` — controls which day starts a week column (0=Sun, 1=Mon…)
103- Automatic timescale updates using `updateTimescaleView`
104- Dynamic timeline mode change at runtime (update `timelineViewMode` + `refresh()`)
105- Timeline cell tooltip visibility using `showTooltip`
106- Timeline template customization using `timelineTemplate` ({ date, value, tier })
107- Infinite timeline scrolling using `enableInfiniteTimelineScroll` (extends the visible range while navigating with horizontal scrollbar or scroll arrows)
108- Timeline navigation using `previousTimeSpan()` / `nextTimeSpan()`
109- Zooming with toolbar (`ZoomIn`, `ZoomOut`, `ZoomToFit`)
110- Customizing zoom steps with `zoomingLevels` (`ZoomTimelineSettings`)
111- Programmatic zoom methods: `zoomIn()`, `zoomOut()`, `fitToProject()`
112- Timeline cell width using `timelineUnitSize`
113- Weekend handling:
114 - Highlight weekends with `highlightWeekends={true}`
115 - Hide weekends using `timelineSettings.showWeekend` (with noted limitations)
116
117### Columns
118📄 **Read:** [references/columns.md](references/columns.md)
119- Column types overview (tree column, WBS, custom columns)
120- Auto-generated columns (omit `ColumnsDirective`)
121- Column rendering with `valueAccessor` (custom display values, concatenation)
122- Expression columns (calculated values via `valueAccessor`)
123- Display serial numbers via `rowDataBound`
124- Tree column configuration (`treeColumnIndex`)
125 - Customize expand/collapse icons (CSS override)
126 - Customize indentation via `queryCellInfo`
127 - `collapseAllParentTasks` — collapse all on load
128 - `taskFields.expandState` — per-row initial expand/collapse
129 - Persist expand/collapse state in `localStorage`
130- WBS (Work Breakdown Structure) column
131 - `enableWBS` + `enableAutoWbsUpdate` APIs
132 - Manual WBS with `taskFields.wbsPredecessor`
133- Column headers, format, and alignment
134 - `headerTemplate` for custom header rendering
135 - Header text wrapping (`treeGrid.textWrapSettings.wrapMode`)
136 - Dynamic header text update (`getColumnByField` + `refreshHeader`)
137- Column templates (custom cell rendering) and `editTemplate`
138- Column spanning and frozen columns (`frozenColumns`, inject `Freeze`)
139
140### Column Interactions
141📄 **Read:** [references/column-interactions.md](references/column-interactions.md)
142- Column resizing (`allowResizing`, inject `Resize`)
143 - Restrict with `minWidth` / `maxWidth` per column
144 - Prevent resize per column (`allowResizing={false}`)
145 - Resize modes: Normal vs Auto (`resizeSettings.mode`)
146 - Programmatic resize (`reorderColumns`, `refreshColumns`)
147 - Resize events: `resizeStart`, `resizing`, `resizeStop`
148- Column reorder (`allowReordering`, inject `Reorder`)
149 - Disable reorder per column (`allowReordering={false}`)
150 - Programmatic reorder: `reorderColumns`, `reorderColumnByIndex`, `reorderColumnByTargetIndex`
151 - Reorder drag events: `columnDragStart`, `columnDrag`, `columnDrop`
152- Column menu (`showColumnMenu`, inject `ColumnMenu`)
153 - Built-in items: SortAscending, SortDescending, AutoFit, AutoFitAll, ColumnChooser, Filter
154 - Custom column menu items + `columnMenuClick` event
155 - Disable per column (`showColumnMenu={false}`)
156- Toggling column visibility (show/hide columns)
157
158### Rows
159📄 **Read:** [references/rows.md](references/rows.md)
160- Row drag-and-drop (reorder and reparent tasks)
161- Indent and outdent (change task hierarchy)
162- Row spanning via `queryCellInfo` event
163 - `QueryCellInfoEventArgs` with `rowSpan`, `colSpan`, `cell`, `data`, `column`
164 - Horizontal spanning (`colSpan`) and vertical spanning (`rowSpan`)
165- Row height configuration
166- Row styling via `rowDataBound`
167- Expand and collapse rows programmatically
168
169### Managing Tasks
170📄 **Read:** [references/managing-tasks.md](references/managing-tasks.md)
171- Adding new tasks (toolbar, context menu, programmatic `addRecord()`)
172- Editing tasks — dialog edit (`mode: 'Dialog'`), cell edit (`mode: 'Auto'`), taskbar drag
173- Deleting tasks (toolbar, `deleteRecord()`, `showDeleteConfirmDialog`)
174- Taskbar drag editing: move, resize right edge, progress handle, dependency drawing
175- Splitting and merging tasks (`taskFields.segments`, `splitTask()`, `mergeTask()`)
176- **Cell edit types** (`editType`): `stringedit`, `numericedit`, `datepickeredit`, `datetimepickeredit`, `dropdownedit`, `booleanedit`
177 - `edit.params` for min/max/step/format/dataSource per column
178- Customizing add/edit dialog fields (`addDialogFields`, `editDialogFields`)
179- Server-side CRUD with `UrlAdaptor` (`url` + `batchUrl`)
180 - Server receives `added`, `changed`, `deleted` arrays in the batch request body
181- Column-level validation rules (`validationRules` on `ColumnDirective`)
182 - Built-in rules: `required`, `min`, `max`, `minLength`, `date`, `regex`
183 - Custom validator functions (`[fn, 'message']` callback pattern)
184
185### Filtering and Searching
186📄 **Read:** [references/filtering-searching.md](references/filtering-searching.md)
187- Basic column filtering (`allowFiltering={true}`, inject `Filter`)
188- Filter hierarchy modes: `Parent`, `Child`, `Both`, `None`
189- Filter menu (string, number, date operators) and Excel-like checklist filter
190- Toolbar search box (`searchSettings`: `fields`, `operator`, `ignoreCase`)
191- Initial filter state on load (`filterSettings.columns` array)
192- Programmatic filter API: `filterByColumn()`, `clearFiltering()`
193- Custom multi-column filter predicates
194
195### Sorting
196📄 **Read:** [references/sorting.md](references/sorting.md)
197- Single-column and multi-column sorting
198- Initial sort state (`sortSettings`)
199- Custom sort comparers
200- Programmatic sorting API
201
202### Selection
203📄 **Read:** [references/selection.md](references/selection.md)
204- Row selection modes (single, multiple)
205- Cell selection
206- Keyboard-based selection
207- Programmatic selection API (`selectRow`, `selectCell`)
208
209### Taskbar, Labels, and Markers
210📄 **Read:** [references/taskbar-labels-markers.md](references/taskbar-labels-markers.md)
211- Taskbar template (custom rendering)
212- Parent taskbar and milestone customization
213- Tooltip settings and templates (`tooltipSettings` for taskbar, connector line, baseline, timeline)
214- Disable/hide tooltips for specific UI targets using `beforeTooltipRender`
215- Left, right, and task label configuration
216- Data markers / indicators
217- Event markers (deadlines, holidays on timeline)
218- Baseline rendering
219- Baseline template customization using `baselineTemplate`
220- Critical path highlighting
221
222### Resources
223📄 **Read:** [references/resources.md](references/resources.md)
224- Defining resource collection (`resources` property)
225- Assigning resources to tasks (`taskFields.resourceInfo`) — single or multiple with custom units
226- Resource view layout (`viewType='ResourceView'`, resource groups)
227- Multi-taskbar (`enableMultiTaskbar={true}`) — multiple taskbars per collapsed resource row
228- Over-allocation highlighting (`showOverAllocatedTasks={true}`)
229- Resource unit and work fields (`resourceFields.unit`, `resourceFields.group`)
230- Custom resource taskbar styling via `queryTaskbarInfo`
231
232### Toolbar
233📄 **Read:** [references/toolbar-context-menu.md](references/toolbar-context-menu.md)
234- Built-in toolbar items: `Add`, `Edit`, `Delete`, `Update`, `Cancel`, `Search`, `ExpandAll`, `CollapseAll`, `Indent`, `Outdent`, `PrevTimeSpan`, `NextTimeSpan`, `ZoomIn`, `ZoomOut`, `ZoomToFit`, `CriticalPath`, `ExcelExport`, `CsvExport`, `PdfExport`, `ColumnChooser`, `Undo`, `Redo`, `SplitTask`, `MergeTask`
235- Required services: `Undo`/`Redo` → `UndoRedo`; `SplitTask`/`MergeTask` → `Edit`; `CriticalPath` → `CriticalPath`; `ExcelExport`/`CsvExport` → `ExcelExport`; `PdfExport` → `PdfExport`; `ColumnChooser` → `ColumnMenu`
236- Custom toolbar buttons using `ItemModel`; handle clicks via `toolbarClick` event (`args.item.id`)
237- Enable/disable toolbar items programmatically via `enableItems()`
238
239### Context Menu
240📄 **Read:** [references/toolbar-context-menu.md](references/toolbar-context-menu.md)
241- Enable with `enableContextMenu={true}`; inject `ContextMenu` service
242- Default context menu items: `AutoFit`, `AutoFitAll`, `SortAscending`, `SortDescending`, `TaskInformation`, `Add`, `Indent`, `Outdent`, `DeleteTask`, `Save`, `Cancel`, `DeleteDependency`, `Convert`, `SplitTask`, `MergeTask`
243- Custom context menu items using `contextMenuItems` array with `target` (`.e-content` or `.e-gridheader`)
244- Handle clicks via `contextMenuClick` event; control visibility via `contextMenuOpen` (`args.hideItems`)
245
246### Excel Export
247📄 **Read:** [references/excel-export.md](references/excel-export.md)
248- Basic Excel export
249- Export properties and customization
250- Exporting multiple Gantt charts to a single Excel workbook
251- Custom data source export
252
253### PDF Export
254📄 **Read:** [references/pdf-export.md](references/pdf-export.md)
255- Basic PDF export
256- Customizing PDF (fonts, columns, styles)
257- Header and footer configuration
258- Page settings (orientation, size)
259
260### Holidays, Working Time & Timezone
261📄 **Read:** [references/holidays-working-time.md](references/holidays-working-time.md)
262- Defining holidays (`holidays` prop, `HolidayModel`, `DayMarkers` service)
263- Work week configuration (`workWeek`, `includeWeekend`)
264- Daily working time (`dayWorkingTime`)
265- Effort-based scheduling (`taskFields.work`, `workUnit`, task types: FixedWork / FixedDuration / FixedUnit)
266- Timezone support (`timezone` prop, IANA timezone strings)
267
268### Splitter
269📄 **Read:** [references/splitter.md](references/splitter.md)
270- Position-based split (`splitterSettings.position` — percentage or pixels)
271- Column-based split (`splitterSettings.columnIndex`)
272- View mode (`splitterSettings.view` — Default / Grid / Chart)
273- Programmatic resize (`setSplitterPosition()`)
274- Splitter events (`splitterResizeStart`, `splitterResizing`, `splitterResized`)
275
276### Scrolling
277📄 **Read:** [references/scrolling.md](references/scrolling.md)
278- Setting `width` and `height` for scrollbar control
279- Responsive container (`width='100%'`, `height='100%'` with CSS parent height)
280- Scroll to a date (`scrollToDate('MM/dd/yyyy')`)
281- Set vertical scroll position (`ganttChartModule.scrollObject.setScrollTop(px)`)
282
283### Virtual Scroll
284📄 **Read:** [references/virtual-scroll.md](references/virtual-scroll.md)
285- Row virtualization (`enableVirtualization={true}`, `VirtualScroll` service)
286- Timeline virtualization (`enableTimelineVirtualization={true}`, requires `projectStartDate` / `projectEndDate`)
287- Combining row + timeline virtualization
288- Accessing filtered record count with virtual scroll (`treeGrid.filterModule.filteredResult`)
289- Virtual scroll limitations (browser memory, cell selection, pixel height, expand state)
290
291### Undo / Redo
292📄 **Read:** [references/undo-redo.md](references/undo-redo.md)
293- Enable undo/redo (`enableUndoRedo`, `UndoRedo` service)
294- `undoRedoActions` — full list of trackable actions and required services
295- `undoRedoStepsCount` — history stack size
296- Toolbar `'Undo'` / `'Redo'` buttons and `Ctrl+Z` / `Ctrl+Y` keyboard shortcuts
297- Programmatic `undo()` / `redo()` via component ref
298
299### State Persistence, Immutable Mode & Loading
300📄 **Read:** [references/state-persistence.md](references/state-persistence.md)
301- State persistence (`enablePersistence={true}`, unique `id` prop, localStorage)
302- Resetting persisted state (change `id` or clear localStorage entry)
303- Immutable mode (`enableImmutableMode={true}`, requires `isPrimaryKey={true}`)
304- Loading animation (`loadingIndicator.indicatorType`: `'Spinner'` or `'Shimmer'`)
305- Manual spinner control (`showSpinner()` / `hideSpinner()`)
306
307### Localization and RTL
308📄 **Read:** [references/localization-rtl.md](references/localization-rtl.md)
309- Setting locale (`locale` prop)
310- Loading custom translations (`L10n.load()` with `'gantt'` namespace keys)
311- Gantt locale key reference (all translatable UI strings)
312- RTL support (`enableRtl={true}`)
313- Column date formatting (`format='yMd'`, `format='dd/MM/yyyy'`)
314- Column number formatting (`format='C2'`, `format='N2'`, `format='P0'`)
315
316### Programmatic Methods
317📄 **Read:** [references/gantt-methods.md](references/gantt-methods.md)
318- Column utilities: `autoFitColumns()`
319- Edit control: `cancelEdit()`, `openAddDialog()`, `openEditDialog()`
320- Task management: `deleteRecord()`, `convertToMilestone()`, `changeTaskMode()`, `updateRecordByID()`, `updateRecordByIndex()`, `updateTaskId()`, `updateDataSource()`, `updateProjectDates()`
321- Toolbar control: `enableItems()`
322- Expand/Collapse: `expandByID()`, `expandByIndex()`, `collapseByID()`, `collapseByIndex()`
323- Undo/Redo stacks: `clearUndoCollection()`, `clearRedoCollection()`, `getUndoActions()`, `getRedoActions()`
324- Data retrieval: `getCurrentViewData()`, `getRecordByID()`, `getTaskByUniqueID()`, `getTaskInfo()`, `getTaskbarHeight()`, `getExpandedRecords()`, `getGanttColumns()`, `getGridColumns()`
325- Formatting helpers: `getDurationString()`, `getWorkString()`
326- DOM access: `getRowByID()`, `getRowByIndex()`
327- Sorting: `removeSortColumn()`
328- Selection: `selectCells()`
329- Row reorder: `reorderRows()`
330- Scrolling: `scrollToTask()`, `updateChartScrollOffset()`
331
332### Events
333📄 **Read:** [references/events.md](references/events.md)
334- Lifecycle events (`load`, `created`, `dataBound`)
335- Task editing events (`actionBegin`, `actionComplete`) with `requestType` reference table
336- Taskbar events: `taskbarEditing`, `taskbarEdited`, `taskbarClick`
337- Row expand/collapse events: `expanding`, `collapsing`, `expanded`, `collapsed`
338- Selection events: `rowSelected`, `rowDeselected`, `cellSelected`, `cellDeselected`
339- Export events: `excelExportComplete`, `pdfExportComplete`
340- Column interaction events: `resizeStart`, `resizing`, `resizeStop`, `columnDragStart`, `columnDrag`, `columnDrop`
341- Event cancellation patterns (`args.cancel = true`)
342- **Complete all-events quick reference table** (30+ events)
343
344---
345
346## Quick Start Example
347
348```tsx
349import * as React from 'react';
350import { GanttComponent, ColumnsDirective, ColumnDirective, Inject, Edit, Toolbar, Selection } from '@syncfusion/ej2-react-gantt';
351import { TaskFieldsModel, EditSettingsModel } from '@syncfusion/ej2-gantt';
352import './App.css';
353
354// In App.css:
355// @import "../node_modules/@syncfusion/ej2-tailwind3-theme/styles/gantt/index.css";
356
357const data = [
358 {
359 TaskID: 1, TaskName: 'Project Initiation',
360 StartDate: new Date('04/02/2024'), EndDate: new Date('04/21/2024'),
361 subtasks: [
362 { TaskID: 2, TaskName: 'Identify Site Location', StartDate: new Date('04/02/2024'), Duration: 4, Progress: 50 },
363 { TaskID: 3, TaskName: 'Perform Soil Test', StartDate: new Date('04/02/2024'), Duration: 4, Progress: 50, Predecessor: '2' },
364 { TaskID: 4, TaskName: 'Soil Test Approval', StartDate: new Date('04/08/2024'), Duration: 0, Predecessor: '3FS', Progress: 50 },
365 ]
366 }
367];
368
369const taskFields: TaskFieldsModel = {
370 id: 'TaskID',
371 name: 'TaskName',
372 startDate: 'StartDate',
373 endDate: 'EndDate',
374 duration: 'Duration',
375 progress: 'Progress',
376 dependency: 'Predecessor',
377 child: 'subtasks',
378};
379
380const editSettings: EditSettingsModel = { allowEditing: true, allowAdding: true, allowDeleting: true, allowTaskbarEditing: true };
381
382function App() {
383 return (
384 <GanttComponent
385 dataSource={data}
386 taskFields={taskFields}
387 editSettings={editSettings}
388 toolbar={['Add', 'Edit', 'Delete', 'Cancel', 'Update', 'Search', 'ZoomIn', 'ZoomOut', 'ZoomToFit']}
389 height="450px"
390 >
391 <ColumnsDirective>
392 <ColumnDirective field="TaskID" width="80" />
393 <ColumnDirective field="TaskName" headerText="Task Name" width="250" />
394 <ColumnDirective field="StartDate" />
395 <ColumnDirective field="Duration" />
396 <ColumnDirective field="Progress" />
397 </ColumnsDirective>
398 <Inject services={[Edit, Toolbar, Selection]} />
399 </GanttComponent>
400 );
401}
402
403export default App;
404```
405
406---
407
408## Common Patterns
409
410### Enable Editing with Dialog
411```tsx
412<GanttComponent
413 editSettings={{ allowEditing: true, mode: 'Dialog' }}
414>
415 <Inject services={[Edit]} />
416</GanttComponent>
417```
418
419### Enable Cell Editing
420```tsx
421<GanttComponent
422 editSettings={{ allowEditing: true, mode: 'Auto' }}
423>
424 <Inject services={[Edit]} />
425</GanttComponent>
426```
427
428### Programmatically Add a Task
429```tsx
430const ganttRef = React.useRef<GanttComponent>(null);
431
432const addTask = () => {
433 ganttRef.current?.addRecord({ TaskID: 10, TaskName: 'New Task', Duration: 3 }, 'Below', 1);
434};
435```
436
437### Export to Excel
438```tsx
439<GanttComponent toolbar={['ExcelExport']} allowExcelExport={true}>
440 <Inject services={[ExcelExport, Toolbar]} />
441</GanttComponent>
442```
443
444### Export to PDF
445```tsx
446<GanttComponent toolbar={['PdfExport']} allowPdfExport={true}>
447 <Inject services={[PdfExport, Toolbar]} />
448</GanttComponent>
449```
450
451### Column-Level Validation Rules
452```tsx
453<ColumnsDirective>
454 <ColumnDirective field="TaskName" validationRules={{ required: true }} />
455 <ColumnDirective field="Duration" validationRules={{ min: 1, max: 100 }} />
456</ColumnsDirective>
457```
458
459### Scroll to Date Programmatically
460```tsx
461const ganttRef = React.useRef<GanttComponent>(null);
462
463ganttRef.current?.scrollToDate('04/28/2024');
464```
465
466### Column Resize with Min/Max Width
467```tsx
468<ColumnDirective field="TaskName" minWidth="100" maxWidth="400" allowResizing={true} />
469```
470
471### Reorder Columns Programmatically
472```tsx
473const ganttRef = React.useRef<GanttComponent>(null);
474
475// By field names:
476(ganttRef.current as any).treeGrid.reorderColumns(['Duration', 'Progress'], 'TaskName');
477
478// By index:
479(ganttRef.current as any).treeGrid.reorderColumnByIndex(2, 0);
480```
481
482### Persist Tree Expand/Collapse State
483```tsx
484// In taskFields — map a boolean field that controls initial expand state:
485const taskFields = { ..., expandState: 'isExpand' };
486
487// Or collapse all on load:
488<GanttComponent collapseAllParentTasks={true} .../>
489```
490
491---
492
493## Key Module Injections
494
495| Feature | Service to Inject |
496|---------|------------------|
497| Editing (add/edit/delete/taskbar drag) | `Edit` |
498| Filtering | `Filter` |
499| Sorting | `Sort` |
500| Toolbar | `Toolbar` |
501| Selection | `Selection` |
502| Day Markers / Holidays / Event Markers | `DayMarkers` |
503| Critical Path | `CriticalPath` |
504| Excel / CSV Export | `ExcelExport` |
505| PDF Export | `PdfExport` |
506| Undo / Redo | `UndoRedo` |
507| Column Menu | `ColumnMenu` |
508| Context Menu | `ContextMenu` |
509| Virtual Scrolling | `VirtualScroll` |
510| Row Drag and Drop | `RowDD` |
511| Column Reordering | `Reorder` |
512| Frozen Columns | `Freeze` |
513| Column Resizing | `Resize` |
514
515Usage pattern:
516```tsx
517import { GanttComponent, Inject, Edit, Filter, Sort, Toolbar, Selection } from '@syncfusion/ej2-react-gantt';
518
519<GanttComponent ...>
520 <Inject services={[Edit, Filter, Sort, Toolbar, Selection]} />
521</GanttComponent>
522```
523
524---
525
526## Key Props Reference
527
528| Prop | Type | Purpose |
529|---|---|---|
530| `dataSource` | object[] / DataManager | Task data (local or remote via DataManager) |
531| `taskFields` | TaskFieldsModel | Field mapping for task properties |
532| `editSettings` | EditSettingsModel | Enable add/edit/delete/taskbar editing |
533| `toolbar` | string[] | Toolbar items to render |
534| `taskMode` | Auto / Manual / Custom | Scheduling mode |
535| `resources` | object[] | Resource data collection |
536| `resourceFields` | ResourceFieldsModel | Resource field mapping |
537| `allowSorting` | boolean | Enable sorting |
538| `allowFiltering` | boolean | Enable filtering |
539| `allowReordering` | boolean | Enable column reorder |
540| `allowResizing` | boolean | Enable column resize |
541| `allowExcelExport` | boolean | Enable Excel export |
542| `allowPdfExport` | boolean | Enable PDF export |
543| `undoRedoActions` | string[] | Actions tracked by undo/redo |
544| `timelineSettings` | TimelineSettingsModel | Timeline tiers and unit config |
545| `splitterSettings` | SplitterSettingsModel | Grid/chart panel ratio |
546| `highlightWeekends` | boolean | Shade weekend columns |
547| `holidays` | HolidayModel[] | Mark holiday dates |
548| `eventMarkers` | EventMarkerModel[] | Vertical markers on timeline |
549| `treeColumnIndex` | number | Column index showing expand/collapse icons |
550| `collapseAllParentTasks` | boolean | Collapse all parent rows on initial load |
551| `enableWBS` | boolean | Auto-generate WBS codes from task hierarchy |
552| `enableAutoWbsUpdate` | boolean | Recalculate WBS codes after CRUD/sort/DnD |
553| `frozenColumns` | number | Number of left-pinned (frozen) columns |
554| `enableMultiTaskbar` | boolean | Show multiple taskbars per resource row |
555| `allowTaskbarOverlap` | boolean | Controls whether multiple taskbars overlap (true, default) or stack with extended row height (false) in resource rows |
556| `viewType` | string | `'ProjectView'` or `'ResourceView'` |
557| `showColumnMenu` | boolean | Show column-level menu (sort, filter, autofit) |
558| `columnMenuItems` | string[] | Restrict which column menu items are shown |
559| `showColumnChooser` | boolean | Enable column chooser dialog via toolbar `ColumnChooser` item |
560| `allowSelection` | boolean | Enable row/cell selection |
561| `selectionSettings` | SelectionSettingsModel | Selection mode (`Row`/`Cell`), type (`Single`/`Multiple`) |
562| `gridLines` | string | Grid lines style: `'Both'` \| `'Horizontal'` \| `'Vertical'` \| `'None'` |
563| `renderBaseline` | boolean | Show baseline bars alongside actual taskbars |
564| `baselineColor` | string | CSS color for baseline bars |
565| `baselineTemplate` | function/string | Custom baseline rendering for planned schedules and advanced baseline layouts |
566| `enableInfiniteTimelineScroll` | boolean | Enable infinite horizontal timeline scrolling by extending the visible range as the user navigates |
567| `enableCriticalPath` | boolean | Highlight critical path tasks and connectors |
568| `enableRtl` | boolean | Enable right-to-left layout |
569| `locale` | string | Locale code (e.g. `'fr'`, `'de'`, `'ar'`) |
570| `allowRowDragAndDrop` | boolean | Enable row drag-and-drop reordering/reparenting |
571| `enableImmutableMode` | boolean | Only re-render changed rows on data updates (requires `isPrimaryKey`) |
572| `enablePersistence` | boolean | Persist UI state (sort, filter, column widths) to localStorage |
573| `loadingIndicator` | object | Loading animation type: `{ indicatorType: 'Spinner' \| 'Shimmer' }` |
574| `workWeek` | string[] | Working days, e.g. `['Monday','Tuesday','Wednesday','Thursday','Friday']` |
575| `includeWeekend` | boolean | Count weekends as working days for duration calculation |
576| `timezone` | string | IANA timezone for the Gantt (e.g. `'America/New_York'`) |
577| `showOverAllocatedTasks` | boolean | Highlight over-allocated resources in ResourceView |
578| `enableUndoRedo` | boolean | Enable undo/redo tracking (inject `UndoRedo` service) |
579| `undoRedoStepsCount` | number | Maximum undo/redo history steps (default: 10) |
580| `enableVirtualization` | boolean | Row virtualization for large data sets |
581| `enableTimelineVirtualization` | boolean | Timeline (horizontal) virtualization |
582| `rowHeight` | number | Uniform row height in pixels |
583| `taskbarHeight` | number | Height of taskbars in pixels (must be ≤ `rowHeight`) |
584| `connectorLineWidth` | number | Width of dependency connector lines |
585| `connectorLineBackground` | string | Color of dependency connector lines |