syncfusion-react-gantt-chart
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSyncfusion React Gantt Chart
Syncfusion React Gantt Chart
The Syncfusion React Gantt Chart () 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.
GanttComponentSyncfusion React Gantt Chart()是一个功能强大的项目管理组件,用于在时间轴上可视化、调度和管理任务。它支持自动/手动调度、任务依赖、资源规划、交互式编辑、Excel/PDF导出以及丰富的自定义功能。
GanttComponentWhen 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
- 在React应用中实现甘特图或项目时间轴
- 配置任务调度(自动、手动、自定义模式)
- 设置任务依赖关系(FS、SS、FF、SF)和约束条件(ASAP、MSO、FNET等)
- 将本地或远程数据绑定到甘特图(本地数组、DataManager、UrlAdaptor、Ajax)
- 自定义任务栏、标签、里程碑和基线
- 配置资源和资源视图(包括多任务栏)
- 启用带验证规则的编辑功能(对话框、单元格、任务栏拖拽)
- 设置列调整大小、重排、冻结或列菜单
- 配置WBS编码、树形列图标或序列号列
- 设置筛选、排序或选择功能
- 滚动到特定日期或通过编程控制滚动位置
- 将甘特图导出为Excel或PDF格式
- 处理甘特图事件并启用高级功能(撤销/重做、虚拟滚动、关键路径等)
- 全球化、本地化和RTL支持
Documentation and Navigation Guide
文档与导航指南
Getting Started
快速入门
📄 Read: references/getting-started.md
- Installation and package dependencies
- Vite / CRA project setup
- CSS theme imports (all 14 required packages)
- Basic with
GanttComponentmappingtaskFields - Module injection guide (all available services)
- prop (
gridLines/'Both'/'Horizontal'/'Vertical')'None' - First render walkthrough with minimal example and common gotchas
📄 阅读: references/getting-started.md
- 安装和包依赖
- Vite / CRA项目设置
- CSS主题导入(全部14个必需包)
- 带映射的基础
taskFieldsGanttComponent - 模块注入指南(所有可用服务)
- 属性(
gridLines/'Both'/'Horizontal'/'Vertical')'None' - 带最小示例和常见问题的首次渲染指南
Data Binding
数据绑定
📄 Read: references/data-binding.md
- Local array data binding
- Remote / AJAX data binding with
DataManager - Self-referential flat data
- configuration (id, name, startDate, endDate, duration, progress, child)
taskFields - Custom field mapping
- UrlAdaptor for server-side CRUD (+
url)batchUrl - RemoteSaveAdaptor for local rendering with server persistence
- Sending additional parameters to server via in
Query.addParams()eventload - Binding with class (manual fetch)
Ajax - Load child on demand (,
loadChildOnDemand={false})hasChildMapping - Handling HTTP errors with event
actionFailure
📄 阅读: references/data-binding.md
- 本地数组数据绑定
- 使用进行远程/AJAX数据绑定
DataManager - 自引用扁平数据
- 配置(id、name、startDate、endDate、duration、progress、child)
taskFields - 自定义字段映射
- UrlAdaptor用于服务端CRUD(+
url)batchUrl - RemoteSaveAdaptor用于本地渲染加服务端持久化
- 通过事件中的
load向服务端发送额外参数Query.addParams() - 使用类进行绑定(手动获取数据)
Ajax - 按需加载子任务(,
loadChildOnDemand={false})hasChildMapping - 通过事件处理HTTP错误
actionFailure
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
📄 阅读: references/task-scheduling.md
- 自动、手动和自定义调度模式()
taskMode - 未调度任务(仅持续时间、仅日期、无)
- 项目开始和结束日期配置
- 调度模式如何影响父任务计算
- 动态切换模式
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 in data source (string format:
taskFields.dependency,"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
- — recalculate offsets on load to account for calendar rules (weekends, holidays)
autoUpdatePredecessorOffset={true} - — display original offsets even if not matching rendered lines (visual inconsistency possible)
autoUpdatePredecessorOffset={false}
- Offset Updates During Editing
- — auto-recalculate offsets when dragging taskbars (default)
updateOffsetOnTaskbarEdit={true} - — preserve offsets; manual update required via dependency dialog
updateOffsetOnTaskbarEdit={false}
- Dependency Validation Modes (in event with
actionBegin)requestType === 'validateLinkedTask'- — revert invalid edits to maintain dependency integrity
respectLink={true} - — remove conflicting dependencies to allow edits
removeLink={true} - — update offsets to maintain links (default mode)
preserveLinkWithEditing={true}
- Validation Dialog — disable all modes to show user-choice dialog (cancel edit, remove link, adjust offset)
- Parent Dependencies — allows cross-parent dependencies;
allowParentDependency={true}restricts to siblings onlyfalse - Show/Hide Dependencies Dynamically — toggle CSS visibility
.e-gantt-dependency-view-container - Disable Validation — disables auto-date validation based on predecessor links
enablePredecessorValidation={false}
📄 阅读: references/task-dependency.md
- 依赖类型:完成-开始(FS)、开始-开始(SS)、完成-完成(FF)、开始-完成(SF)
- 在数据源中映射(字符串格式:
taskFields.dependency、"2FS"、"2FS+3d")"2SS+2h" - 每个任务的多个前置任务(逗号分隔:)
"2FS,3FS" - 带单位的偏移值:天、小时、分钟(例如、
"2FS+3h")"2FS-1d" - 通过UI绘制依赖关系(从任务栏连接点拖拽)
- 程序化管理依赖关系(、
addPredecessor、removePredecessor)updatePredecessor - 连接线自定义(、
connectorLineWidth)connectorLineBackground - 前置任务偏移同步
- — 加载时重新计算偏移量以适应日历规则(周末、节假日)
autoUpdatePredecessorOffset={true} - — 显示原始偏移量,即使与渲染线条不匹配(可能存在视觉不一致)
autoUpdatePredecessorOffset={false}
- 编辑期间的偏移更新
- — 拖拽任务栏时自动重新计算偏移量(默认)
updateOffsetOnTaskbarEdit={true} - — 保留偏移量;需通过依赖对话框手动更新
updateOffsetOnTaskbarEdit={false}
- 依赖验证模式(在事件中,
actionBegin)requestType === 'validateLinkedTask'- — 撤销无效编辑以维护依赖完整性
respectLink={true} - — 删除冲突依赖以允许编辑
removeLink={true} - — 更新偏移量以维持链接(默认模式)
preserveLinkWithEditing={true}
- 验证对话框 — 禁用所有模式以显示用户选择对话框(取消编辑、删除链接、调整偏移量)
- 父任务依赖 — 允许跨父任务依赖;
allowParentDependency={true}仅限制为同级任务false - 动态显示/隐藏依赖关系 — 切换的CSS可见性
.e-gantt-dependency-view-container - 禁用验证 — 禁用基于前置任务链接的自动日期验证
enablePredecessorValidation={false}
Task Constraints
任务约束
📄 Read: references/task-constraints.md
- Eight constraint types: ASAP, ALAP, MSO, MFO, SNET, SNLT, FNET, FNLT
- Mapping and
taskFields.constraintTypetaskFields.constraintDate - How constraints interact with dependencies and
taskMode - Editing constraints via dialog
- Validation and conflict handling
📄 阅读: references/task-constraints.md
- 八种约束类型:ASAP、ALAP、MSO、MFO、SNET、SNLT、FNET、FNLT
- 映射和
taskFields.constraintTypetaskFields.constraintDate - 约束如何与依赖关系和交互
taskMode - 通过对话框编辑约束
- 验证和冲突处理
Timeline and Zooming
时间轴与缩放
📄 Read: references/timeline.md
- quick presets (
timelineViewMode,Hour,Day,Week,Month)Year - Top tier and bottom tier independent configuration (,
unit,format,count)formatter - Custom timeline cell rendering via function
formatter - — pixel width per cell
timelineUnitSize - — controls which day starts a week column (0=Sun, 1=Mon…)
weekStartDay - Weekend highlighting ()
highlightWeekends={true} - Zoom in, zoom out, zoom to fit (toolbar + programmatic ,
zoomIn(),zoomOut())fitToProject()
📄 阅读: references/timeline.md
- 快速预设(
timelineViewMode、Hour、Day、Week、Month)Year - 顶层和底层独立配置(、
unit、format、count)formatter - 通过函数自定义时间轴单元格渲染
formatter - — 每个单元格的像素宽度
timelineUnitSize - — 控制周列从哪一天开始(0=周日,1=周一…)
weekStartDay - 周末高亮()
highlightWeekends={true} - 放大、缩小、适合窗口(工具栏 + 程序化、
zoomIn()、zoomOut())fitToProject()
Columns
列
📄 Read: references/columns.md
- Column types overview (tree column, WBS, custom columns)
- Auto-generated columns (omit )
ColumnsDirective - Column rendering with (custom display values, concatenation)
valueAccessor - 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 - — collapse all on load
collapseAllParentTasks - — per-row initial expand/collapse
taskFields.expandState - Persist expand/collapse state in
localStorage
- WBS (Work Breakdown Structure) column
- +
enableWBSAPIsenableAutoWbsUpdate - Manual WBS with
taskFields.wbsPredecessor
- Column headers, format, and alignment
- for custom header rendering
headerTemplate - Header text wrapping ()
treeGrid.textWrapSettings.wrapMode - Dynamic header text update (+
getColumnByField)refreshHeader
- Column templates (custom cell rendering) and
editTemplate - Column spanning and frozen columns (, inject
frozenColumns)Freeze
📄 阅读: references/columns.md
- 列类型概述(树形列、WBS、自定义列)
- 自动生成列(省略)
ColumnsDirective - 使用渲染列(自定义显示值、拼接)
valueAccessor - 表达式列(通过计算值)
valueAccessor - 通过显示序列号
rowDataBound - 树形列配置()
treeColumnIndex- 自定义展开/折叠图标(CSS覆盖)
- 通过自定义缩进
queryCellInfo - — 加载时全部折叠
collapseAllParentTasks - — 每行初始展开/折叠状态
taskFields.expandState - 在中持久化展开/折叠状态
localStorage
- WBS(工作分解结构)列
- +
enableWBSAPIenableAutoWbsUpdate - 使用手动设置WBS
taskFields.wbsPredecessor
- 列标题、格式和对齐
- 用于自定义标题渲染
headerTemplate - 标题文本换行()
treeGrid.textWrapSettings.wrapMode - 动态更新标题文本(+
getColumnByField)refreshHeader
- 列模板(自定义单元格渲染)和
editTemplate - 列合并和冻结列(,注入
frozenColumns)Freeze
Column Interactions
列交互
📄 Read: references/column-interactions.md
- Column resizing (, inject
allowResizing)Resize- Restrict with /
minWidthper columnmaxWidth - Prevent resize per column ()
allowResizing={false} - Resize modes: Normal vs Auto ()
resizeSettings.mode - Programmatic resize (,
reorderColumns)refreshColumns - Resize events: ,
resizeStart,resizingresizeStop
- Restrict with
- Column reorder (, inject
allowReordering)Reorder- Disable reorder per column ()
allowReordering={false} - Programmatic reorder: ,
reorderColumns,reorderColumnByIndexreorderColumnByTargetIndex - Reorder drag events: ,
columnDragStart,columnDragcolumnDrop
- Disable reorder per column (
- Column menu (, inject
showColumnMenu)ColumnMenu- Built-in items: SortAscending, SortDescending, AutoFit, AutoFitAll, ColumnChooser, Filter
- Custom column menu items + event
columnMenuClick - Disable per column ()
showColumnMenu={false}
- Toggling column visibility (show/hide columns)
📄 阅读: references/column-interactions.md
- 列调整大小(,注入
allowResizing)Resize- 通过/
minWidth限制每列maxWidth - 禁止某列调整大小()
allowResizing={false} - 调整大小模式:普通 vs 自动()
resizeSettings.mode - 程序化调整大小(、
reorderColumns)refreshColumns - 调整大小事件:、
resizeStart、resizingresizeStop
- 通过
- 列重排(,注入
allowReordering)Reorder- 禁止某列重排()
allowReordering={false} - 程序化重排:、
reorderColumns、reorderColumnByIndexreorderColumnByTargetIndex - 重排拖拽事件:、
columnDragStart、columnDragcolumnDrop
- 禁止某列重排(
- 列菜单(,注入
showColumnMenu)ColumnMenu- 内置项:SortAscending、SortDescending、AutoFit、AutoFitAll、ColumnChooser、Filter
- 自定义列菜单项 + 事件
columnMenuClick - 禁止某列显示菜单()
showColumnMenu={false}
- 切换列可见性(显示/隐藏列)
Rows
行
📄 Read: references/rows.md
- Row drag-and-drop (reorder and reparent tasks)
- Indent and outdent (change task hierarchy)
- Row spanning via event
queryCellInfo- with
QueryCellInfoEventArgs,rowSpan,colSpan,cell,datacolumn - Horizontal spanning () and vertical spanning (
colSpan)rowSpan
- Row height configuration
- Row styling via
rowDataBound - Expand and collapse rows programmatically
📄 阅读: references/rows.md
- 行拖拽(重新排序和重排任务层级)
- 缩进和取消缩进(更改任务层级)
- 通过事件实现行合并
queryCellInfo- 包含
QueryCellInfoEventArgs、rowSpan、colSpan、cell、datacolumn - 水平合并()和垂直合并(
colSpan)rowSpan
- 行高配置
- 通过设置行样式
rowDataBound - 程序化展开和折叠行
Managing Tasks
任务管理
📄 Read: references/managing-tasks.md
- Adding new tasks (toolbar, context menu, programmatic )
addRecord() - Editing tasks — dialog edit (), cell edit (
mode: 'Dialog'), taskbar dragmode: 'Auto' - Deleting tasks (toolbar, ,
deleteRow())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,dropdowneditbooleanedit- for min/max/step/format/dataSource per column
edit.params
- Customizing add/edit dialog fields (,
addDialogFields)editDialogFields - Server-side CRUD with (
UrlAdaptor+url)batchUrl- Server receives ,
added,changedarrays in the batch request bodydeleted
- Server receives
- Column-level validation rules (on
validationRules)ColumnDirective- Built-in rules: ,
required,min,max,minLength,dateregex - Custom validator functions (callback pattern)
[fn, 'message']
- Built-in rules:
📄 阅读: references/managing-tasks.md
- 添加新任务(工具栏、上下文菜单、程序化)
addRecord() - 编辑任务 — 对话框编辑()、单元格编辑(
mode: 'Dialog')、任务栏拖拽mode: 'Auto' - 删除任务(工具栏、、
deleteRow())showDeleteConfirmDialog - 任务栏拖拽编辑:移动、调整右边缘、进度手柄、依赖关系绘制
- 拆分和合并任务(、
taskFields.segments、splitTask())mergeTask() - 单元格编辑类型():
editType、stringedit、numericedit、datepickeredit、datetimepickeredit、dropdowneditbooleanedit- 用于每列的最小/最大/步长/格式/数据源
edit.params
- 自定义添加/编辑对话框字段(、
addDialogFields)editDialogFields - 使用进行服务端CRUD(
UrlAdaptor+url)batchUrl- 服务端在批量请求体中接收、
added、changed数组deleted
- 服务端在批量请求体中接收
- 列级验证规则(上的
ColumnDirective)validationRules- 内置规则:、
required、min、max、minLength、dateregex - 自定义验证器函数(回调模式)
[fn, 'message']
- 内置规则:
Filtering and Searching
筛选与搜索
📄 Read: references/filtering-searching.md
- Basic column filtering (, inject
allowFiltering={true})Filter - Filter hierarchy modes: ,
Parent,Child,BothNone - Filter menu (string, number, date operators) and Excel-like checklist filter
- Toolbar search box (:
searchSettings,fields,operator)ignoreCase - Initial filter state on load (array)
filterSettings.columns - Programmatic filter API: ,
filterByColumn()clearFiltering() - Custom multi-column filter predicates
📄 阅读: references/filtering-searching.md
- 基础列筛选(,注入
allowFiltering={true})Filter - 筛选层级模式:、
Parent、Child、BothNone - 筛选菜单(字符串、数字、日期运算符)和类Excel的复选框筛选
- 工具栏搜索框(:
searchSettings、fields、operator)ignoreCase - 加载时的初始筛选状态(数组)
filterSettings.columns - 程序化筛选API:、
filterByColumn()clearFiltering() - 自定义多列筛选谓词
Sorting
排序
📄 Read: references/sorting.md
- Single-column and multi-column sorting
- Initial sort state ()
sortSettings - Custom sort comparers
- Programmatic sorting API
📄 阅读: references/sorting.md
- 单列和多列排序
- 初始排序状态()
sortSettings - 自定义排序比较器
- 程序化排序API
Selection
选择
📄 Read: references/selection.md
- Row selection modes (single, multiple)
- Cell selection
- Keyboard-based selection
- Programmatic selection API (,
selectRow)selectCell
📄 阅读: references/selection.md
- 行选择模式(单选、多选)
- 单元格选择
- 基于键盘的选择
- 程序化选择API(、
selectRow)selectCell
Taskbar, Labels, and Markers
任务栏、标签与标记
📄 Read: references/taskbar-labels-markers.md
- Taskbar template (custom rendering)
- Parent taskbar and milestone customization
- Left, right, and task label configuration
- Data markers / indicators
- Event markers (deadlines, holidays on timeline)
- Baseline rendering
- Critical path highlighting
📄 阅读: references/taskbar-labels-markers.md
- 任务栏模板(自定义渲染)
- 父任务栏和里程碑自定义
- 左侧、右侧和任务标签配置
- 数据标记/指示器
- 事件标记(时间轴上的截止日期、节假日)
- 基线渲染
- 关键路径高亮
Resources
资源
📄 Read: references/resources.md
- Defining resource collection (property)
resources - Assigning resources to tasks () — single or multiple with custom units
taskFields.resourceInfo - Resource view layout (, resource groups)
viewType='ResourceView' - Multi-taskbar () — multiple taskbars per collapsed resource row
enableMultiTaskbar={true} - Over-allocation highlighting ()
showOverAllocatedTasks={true} - Resource unit and work fields (,
resourceFields.unit)resourceFields.group - Custom resource taskbar styling via
queryTaskbarInfo
📄 阅读: references/resources.md
- 定义资源集合(属性)
resources - 为任务分配资源()— 单个或多个带自定义单位
taskFields.resourceInfo - 资源视图布局(,资源组)
viewType='ResourceView' - 多任务栏()— 折叠资源行显示多个任务栏
enableMultiTaskbar={true} - 过度分配高亮()
showOverAllocatedTasks={true} - 资源单位和工作字段(、
resourceFields.unit)resourceFields.group - 通过自定义资源任务栏样式
queryTaskbarInfo
Toolbar and Context Menu
工具栏与上下文菜单
📄 Read: references/toolbar-context-menu.md
- Built-in toolbar items: ,
Add,Edit,Delete,Update,Cancel,Search,ExpandAll,CollapseAll,Indent,Outdent,ZoomIn,ZoomOut,ZoomToFit,CriticalPath,ExcelExport,CsvExport,PdfExport,ColumnChooser,Undo,Redo,SplitTaskMergeTask - Required services per toolbar item (e.g. /
Undo→Redo,UndoRedo→SplitTask)Edit - Custom toolbar buttons () and
ItemModelhandlertoolbarClick - Default context menu items including ,
SplitTask,MergeTask,ConvertDeleteDependency - Custom context menu items, ,
contextMenuClick(contextMenuOpen)args.hideItems - Enabling/disabling toolbar items dynamically
📄 阅读: references/toolbar-context-menu.md
- 内置工具栏项:、
Add、Edit、Delete、Update、Cancel、Search、ExpandAll、CollapseAll、Indent、Outdent、ZoomIn、ZoomOut、ZoomToFit、CriticalPath、ExcelExport、CsvExport、PdfExport、ColumnChooser、Undo、Redo、SplitTaskMergeTask - 每个工具栏项所需的服务(例如/
Undo→Redo,UndoRedo→SplitTask)Edit - 自定义工具栏按钮()和
ItemModel处理程序toolbarClick - 默认上下文菜单项包括、
SplitTask、MergeTask、ConvertDeleteDependency - 自定义上下文菜单项、、
contextMenuClick(contextMenuOpen)args.hideItems - 动态启用/禁用工具栏项
Excel Export
Excel导出
📄 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
📄 阅读: references/excel-export.md
- 基础Excel导出
- 导出属性和自定义
- 将多个甘特图导出到单个Excel工作簿
- 自定义数据源导出
PDF Export
PDF导出
📄 Read: references/pdf-export.md
- Basic PDF export
- Customizing PDF (fonts, columns, styles)
- Header and footer configuration
- Page settings (orientation, size)
📄 阅读: references/pdf-export.md
- 基础PDF导出
- 自定义PDF(字体、列、样式)
- 页眉和页脚配置
- 页面设置(方向、大小)
Holidays, Working Time & Timezone
节假日、工作时间与时区
📄 Read: references/holidays-working-time.md
- Defining holidays (prop,
holidays,HolidayModelservice)DayMarkers - Work week configuration (,
workWeek)includeWeekend - Daily working time ()
dayWorkingTime - Effort-based scheduling (,
taskFields.work, task types: FixedWork / FixedDuration / FixedUnit)workUnit - Timezone support (prop, IANA timezone strings)
timezone
📄 阅读: references/holidays-working-time.md
- 定义节假日(属性、
holidays、HolidayModel服务)DayMarkers - 工作周配置(、
workWeek)includeWeekend - 每日工作时间()
dayWorkingTime - 基于工作量的调度(、
taskFields.work,任务类型:FixedWork / FixedDuration / FixedUnit)workUnit - 时区支持(属性,IANA时区字符串)
timezone
Splitter
拆分器
📄 Read: references/splitter.md
- Position-based split (— percentage or pixels)
splitterSettings.position - Column-based split ()
splitterSettings.columnIndex - View mode (— Default / Grid / Chart)
splitterSettings.view - Programmatic resize ()
setSplitterPosition() - Splitter events (,
splitterResizeStart,splitterResizing)splitterResized
📄 阅读: references/splitter.md
- 基于位置的拆分(— 百分比或像素)
splitterSettings.position - 基于列的拆分()
splitterSettings.columnIndex - 视图模式(— Default / Grid / Chart)
splitterSettings.view - 程序化调整大小()
setSplitterPosition() - 拆分器事件(、
splitterResizeStart、splitterResizing)splitterResized
Scrolling
滚动
📄 Read: references/scrolling.md
- Setting and
widthfor scrollbar controlheight - Responsive container (,
width='100%'with CSS parent height)height='100%' - Scroll to a date ()
scrollToDate('MM/dd/yyyy') - Set vertical scroll position ()
ganttChartModule.scrollObject.setScrollTop(px)
📄 阅读: references/scrolling.md
- 设置和
width以控制滚动条height - 响应式容器(、
width='100%'配合CSS父元素高度)height='100%' - 滚动到指定日期()
scrollToDate('MM/dd/yyyy') - 设置垂直滚动位置()
ganttChartModule.scrollObject.setScrollTop(px)
Virtual Scroll
虚拟滚动
📄 Read: references/virtual-scroll.md
- Row virtualization (,
enableVirtualization={true}service)VirtualScroll - Timeline virtualization (, requires
enableTimelineVirtualization={true}/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)
📄 阅读: references/virtual-scroll.md
- 行虚拟化(,
enableVirtualization={true}服务)VirtualScroll - 时间轴虚拟化(,需要
enableTimelineVirtualization={true}/projectStartDate)projectEndDate - 行 + 时间轴虚拟化结合
- 虚拟滚动下获取筛选记录数()
treeGrid.filterModule.filteredResult - 虚拟滚动限制(浏览器内存、单元格选择、像素高度、展开状态)
Undo / Redo
撤销/重做
📄 Read: references/undo-redo.md
- Enable undo/redo (,
enableUndoRedoservice)UndoRedo - — full list of trackable actions and required services
undoRedoActions - — history stack size
undoRedoStepsCount - Toolbar /
'Undo'buttons and'Redo'/Ctrl+Zkeyboard shortcutsCtrl+Y - Programmatic /
undo()via component refredo()
📄 阅读: references/undo-redo.md
- 启用撤销/重做(,
enableUndoRedo服务)UndoRedo - — 可跟踪操作的完整列表和所需服务
undoRedoActions - — 历史栈大小
undoRedoStepsCount - 工具栏/
'Undo'按钮和'Redo'/Ctrl+Z键盘快捷键Ctrl+Y - 通过组件引用程序化执行/
undo()redo()
State Persistence, Immutable Mode & Loading
状态持久化、不可变模式与加载
📄 Read: references/state-persistence.md
- State persistence (, unique
enablePersistence={true}prop, localStorage)id - Resetting persisted state (change or clear localStorage entry)
id - Immutable mode (, requires
enableImmutableMode={true})isPrimaryKey={true} - Loading animation (:
loadingIndicator.indicatorTypeor'Spinner')'Shimmer' - Manual spinner control (/
showSpinner())hideSpinner()
📄 阅读: references/state-persistence.md
- 状态持久化(,唯一
enablePersistence={true}属性,localStorage)id - 重置持久化状态(更改或清除localStorage条目)
id - 不可变模式(,需要
enableImmutableMode={true})isPrimaryKey={true} - 加载动画(:
loadingIndicator.indicatorType或'Spinner')'Shimmer' - 手动控制加载指示器(/
showSpinner())hideSpinner()
Localization and RTL
本地化与RTL
📄 Read: references/localization-rtl.md
- Setting locale (prop)
locale - Loading custom translations (with
L10n.load()namespace keys)'gantt' - 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'
📄 阅读: references/localization-rtl.md
- 设置区域设置(属性)
locale - 加载自定义翻译(配合
L10n.load()命名空间键)'gantt' - 甘特图区域设置键参考(所有可翻译UI字符串)
- RTL支持()
enableRtl={true} - 列日期格式化(、
format='yMd')format='dd/MM/yyyy' - 列数字格式化(、
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: ,
expandByIndex()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()
📄 阅读: references/gantt-methods.md
- 列工具:
autoFitColumns() - 编辑控制:、
cancelEdit()、openAddDialog()openEditDialog() - 任务管理:、
deleteRecord()、convertToMilestone()、changeTaskMode()、updateRecordByID()、updateRecordByIndex()、updateTaskId()、updateDataSource()updateProjectDates() - 工具栏控制:
enableItems() - 展开/折叠:、
expandByIndex()collapseByIndex() - 撤销/重做栈:、
clearUndoCollection()、clearRedoCollection()、getUndoActions()getRedoActions() - 数据检索:、
getCurrentViewData()、getRecordByID()、getTaskByUniqueID()、getTaskInfo()、getTaskbarHeight()、getExpandedRecords()、getGanttColumns()getGridColumns() - 格式化助手:、
getDurationString()getWorkString() - DOM访问:、
getRowByID()getRowByIndex() - 排序:
removeSortColumn() - 选择:
selectCells() - 行重排:
reorderRows() - 滚动:、
scrollToTask()updateChartScrollOffset()
Events
事件
📄 Read: references/events.md
- Lifecycle events (,
load,created)dataBound - Task editing events (,
actionBegin) withactionCompletereference tablerequestType - Taskbar events: ,
taskbarEditing,taskbarEditedtaskbarClick - Row expand/collapse events: ,
expanding,collapsing,expandedcollapsed - Selection events: ,
rowSelected,rowDeselected,cellSelectedcellDeselected - Export events: ,
excelExportCompletepdfExportComplete - Column interaction events: ,
resizeStart,resizing,resizeStop,columnDragStart,columnDragcolumnDrop - Event cancellation patterns ()
args.cancel = true - Complete all-events quick reference table (30+ events)
📄 阅读: references/events.md
- 生命周期事件(、
load、created)dataBound - 任务编辑事件(、
actionBegin)带actionComplete参考表requestType - 任务栏事件:、
taskbarEditing、taskbarEditedtaskbarClick - 行展开/折叠事件:、
expanding、collapsing、expandedcollapsed - 选择事件:、
rowSelected、rowDeselected、cellSelectedcellDeselected - 导出事件:、
excelExportCompletepdfExportComplete - 列交互事件:、
resizeStart、resizing、resizeStop、columnDragStart、columnDragcolumnDrop - 事件取消模式()
args.cancel = true - 完整事件速查表(30+事件)
Quick Start Example
快速入门示例
tsx
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';
// In App.css:
// @import "../node_modules/@syncfusion/ej2-gantt/styles/tailwind3.css";
// (plus base, buttons, calendars, dropdowns, grids, inputs, layouts,
// lists, navigations, notifications, popups, richtexteditor, treegrid)
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;tsx
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';
// 在App.css中:
// @import "../node_modules/@syncfusion/ej2-gantt/styles/tailwind3.css";
// (加上base、buttons、calendars、dropdowns、grids、inputs、layouts,
// lists、navigations、notifications、popups、richtexteditor、treegrid)
const data = [
{
TaskID: 1, TaskName: '项目启动',
StartDate: new Date('04/02/2024'), EndDate: new Date('04/21/2024'),
subtasks: [
{ TaskID: 2, TaskName: '确定场地位置', StartDate: new Date('04/02/2024'), Duration: 4, Progress: 50 },
{ TaskID: 3, TaskName: '进行土壤测试', StartDate: new Date('04/02/2024'), Duration: 4, Progress: 50, Predecessor: '2' },
{ TaskID: 4, TaskName: '土壤测试审批', 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="任务名称" 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
启用对话框编辑
tsx
<GanttComponent
editSettings={{ allowEditing: true, mode: 'Dialog' }}
>
<Inject services={[Edit]} />
</GanttComponent>tsx
<GanttComponent
editSettings={{ allowEditing: true, mode: 'Dialog' }}
>
<Inject services={[Edit]} />
</GanttComponent>Enable Cell Editing
启用单元格编辑
tsx
<GanttComponent
editSettings={{ allowEditing: true, mode: 'Auto' }}
>
<Inject services={[Edit]} />
</GanttComponent>tsx
<GanttComponent
editSettings={{ allowEditing: true, mode: 'Auto' }}
>
<Inject services={[Edit]} />
</GanttComponent>Programmatically Add a Task
程序化添加任务
tsx
const ganttRef = React.useRef<GanttComponent>(null);
const addTask = () => {
ganttRef.current?.addRecord({ TaskID: 10, TaskName: 'New Task', Duration: 3 }, 'Below', 1);
};tsx
const ganttRef = React.useRef<GanttComponent>(null);
const addTask = () => {
ganttRef.current?.addRecord({ TaskID: 10, TaskName: '新任务', Duration: 3 }, 'Below', 1);
};Export to Excel
导出为Excel
tsx
<GanttComponent toolbar={['ExcelExport']} allowExcelExport={true}>
<Inject services={[ExcelExport, Toolbar]} />
</GanttComponent>tsx
<GanttComponent toolbar={['ExcelExport']} allowExcelExport={true}>
<Inject services={[ExcelExport, Toolbar]} />
</GanttComponent>Export to PDF
导出为PDF
tsx
<GanttComponent toolbar={['PdfExport']} allowPdfExport={true}>
<Inject services={[PdfExport, Toolbar]} />
</GanttComponent>tsx
<GanttComponent toolbar={['PdfExport']} allowPdfExport={true}>
<Inject services={[PdfExport, Toolbar]} />
</GanttComponent>Column-Level Validation Rules
列级验证规则
tsx
<ColumnsDirective>
<ColumnDirective field="TaskName" validationRules={{ required: true }} />
<ColumnDirective field="Duration" validationRules={{ min: 1, max: 100 }} />
</ColumnsDirective>tsx
<ColumnsDirective>
<ColumnDirective field="TaskName" validationRules={{ required: true }} />
<ColumnDirective field="Duration" validationRules={{ min: 1, max: 100 }} />
</ColumnsDirective>Scroll to Date Programmatically
程序化滚动到指定日期
tsx
const ganttRef = React.useRef<GanttComponent>(null);
ganttRef.current?.scrollToDate('04/28/2024');tsx
const ganttRef = React.useRef<GanttComponent>(null);
ganttRef.current?.scrollToDate('04/28/2024');Column Resize with Min/Max Width
带最小/最大宽度的列调整
tsx
<ColumnDirective field="TaskName" minWidth="100" maxWidth="400" allowResizing={true} />tsx
<ColumnDirective field="TaskName" minWidth="100" maxWidth="400" allowResizing={true} />Reorder Columns Programmatically
程序化重排列
tsx
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);tsx
const ganttRef = React.useRef<GanttComponent>(null);
// 通过字段名称:
(ganttRef.current as any).treeGrid.reorderColumns(['Duration', 'Progress'], 'TaskName');
// 通过索引:
(ganttRef.current as any).treeGrid.reorderColumnByIndex(2, 0);Persist Tree Expand/Collapse State
持久化树形展开/折叠状态
tsx
// In taskFields — map a boolean field that controls initial expand state:
const taskFields = { ..., expandState: 'isExpand' };
// Or collapse all on load:
<GanttComponent collapseAllParentTasks={true} .../>tsx
// 在taskFields中 — 映射一个控制初始展开状态的布尔字段:
const taskFields = { ..., expandState: 'isExpand' };
// 或加载时全部折叠:
<GanttComponent collapseAllParentTasks={true} .../>Key Module Injections
关键模块注入
| Feature | Service to Inject |
|---|---|
| Editing (add/edit/delete/taskbar drag) | |
| Filtering | |
| Sorting | |
| Toolbar | |
| Selection | |
| Day Markers / Holidays / Event Markers | |
| Critical Path | |
| Excel / CSV Export | |
| PDF Export | |
| Undo / Redo | |
| Column Menu | |
| Context Menu | |
| Virtual Scrolling | |
| Row Drag and Drop | |
| Column Reordering | |
| Frozen Columns | |
| Column Resizing | |
Usage pattern:
tsx
import { GanttComponent, Inject, Edit, Filter, Sort, Toolbar, Selection } from '@syncfusion/ej2-react-gantt';
<GanttComponent ...>
<Inject services={[Edit, Filter, Sort, Toolbar, Selection]} />
</GanttComponent>| 功能 | 需注入的服务 |
|---|---|
| 编辑(添加/编辑/删除/任务栏拖拽) | |
| 筛选 | |
| 排序 | |
| 工具栏 | |
| 选择 | |
| 日期标记 / 节假日 / 事件标记 | |
| 关键路径 | |
| Excel / CSV导出 | |
| PDF导出 | |
| 撤销/重做 | |
| 列菜单 | |
| 上下文菜单 | |
| 虚拟滚动 | |
| 行拖拽 | |
| 列重排 | |
| 冻结列 | |
| 列调整大小 | |
使用模式:
tsx
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 |
|---|---|---|
| object[] / DataManager | Task data (local or remote via DataManager) |
| TaskFieldsModel | Field mapping for task properties |
| EditSettingsModel | Enable add/edit/delete/taskbar editing |
| string[] | Toolbar items to render |
| Auto / Manual / Custom | Scheduling mode |
| object[] | Resource data collection |
| ResourceFieldsModel | Resource field mapping |
| boolean | Enable sorting |
| boolean | Enable filtering |
| boolean | Enable column reorder |
| boolean | Enable column resize |
| boolean | Enable Excel export |
| boolean | Enable PDF export |
| string[] | Actions tracked by undo/redo |
| TimelineSettingsModel | Timeline tiers and unit config |
| SplitterSettingsModel | Grid/chart panel ratio |
| boolean | Shade weekend columns |
| HolidayModel[] | Mark holiday dates |
| EventMarkerModel[] | Vertical markers on timeline |
| number | Column index showing expand/collapse icons |
| boolean | Collapse all parent rows on initial load |
| boolean | Auto-generate WBS codes from task hierarchy |
| boolean | Recalculate WBS codes after CRUD/sort/DnD |
| number | Number of left-pinned (frozen) columns |
| boolean | Show multiple taskbars per resource row |
| string | |
| boolean | Show column-level menu (sort, filter, autofit) |
| string[] | Restrict which column menu items are shown |
| boolean | Enable column chooser dialog via toolbar |
| boolean | Enable row/cell selection |
| SelectionSettingsModel | Selection mode ( |
| string | Grid lines style: |
| boolean | Show baseline bars alongside actual taskbars |
| string | CSS color for baseline bars |
| boolean | Highlight critical path tasks and connectors |
| boolean | Enable right-to-left layout |
| string | Locale code (e.g. |
| boolean | Enable row drag-and-drop reordering/reparenting |
| boolean | Only re-render changed rows on data updates (requires |
| boolean | Persist UI state (sort, filter, column widths) to localStorage |
| object | Loading animation type: |
| string[] | Working days, e.g. |
| boolean | Count weekends as working days for duration calculation |
| string | IANA timezone for the Gantt (e.g. |
| boolean | Highlight over-allocated resources in ResourceView |
| boolean | Enable undo/redo tracking (inject |
| number | Maximum undo/redo history steps (default: 10) |
| boolean | Row virtualization for large data sets |
| boolean | Timeline (horizontal) virtualization |
| number | Uniform row height in pixels |
| number | Height of taskbars in pixels (must be ≤ |
| number | Width of dependency connector lines |
| string | Color of dependency connector lines |
| 属性 | 类型 | 用途 |
|---|---|---|
| object[] / DataManager | 任务数据(本地或通过DataManager远程获取) |
| TaskFieldsModel | 任务属性的字段映射 |
| EditSettingsModel | 启用添加/编辑/删除/任务栏编辑 |
| string[] | 要渲染的工具栏项 |
| Auto / Manual / Custom | 调度模式 |
| object[] | 资源数据集合 |
| ResourceFieldsModel | 资源字段映射 |
| boolean | 启用排序 |
| boolean | 启用筛选 |
| boolean | 启用列重排 |
| boolean | 启用列调整大小 |
| boolean | 启用Excel导出 |
| boolean | 启用PDF导出 |
| string[] | 撤销/重做跟踪的操作 |
| TimelineSettingsModel | 时间轴层级和单位配置 |
| SplitterSettingsModel | 网格/图表面板比例 |
| boolean | 高亮周末列 |
| HolidayModel[] | 标记节假日日期 |
| EventMarkerModel[] | 时间轴上的垂直标记 |
| number | 显示展开/折叠图标的列索引 |
| boolean | 初始加载时折叠所有父行 |
| boolean | 根据任务层级自动生成WBS编码 |
| boolean | CRUD/排序/拖拽后重新计算WBS编码 |
| number | 左侧固定(冻结)的列数 |
| boolean | 每个资源行显示多个任务栏 |
| string | |
| boolean | 显示列级菜单(排序、筛选、自动调整) |
| string[] | 限制显示的列菜单项 |
| boolean | 通过工具栏 |
| boolean | 启用行/单元格选择 |
| SelectionSettingsModel | 选择模式( |
| string | 网格线样式: |
| boolean | 在实际任务栏旁边显示基线栏 |
| string | 基线栏的CSS颜色 |
| boolean | 高亮关键路径任务和连接线 |
| boolean | 启用从右到左布局 |
| string | 区域设置代码(例如 |
| boolean | 启用行拖拽重排/重设层级 |
| boolean | 数据更新时仅重新渲染更改的行(需要 |
| boolean | 将UI状态(排序、筛选、列宽)持久化到localStorage |
| object | 加载动画类型: |
| string[] | 工作日,例如 |
| boolean | 计算持续时间时将周末算作工作日 |
| string | 甘特图的IANA时区(例如 |
| boolean | 在资源视图中高亮过度分配的资源 |
| boolean | 启用撤销/重做跟踪(需注入 |
| number | 最大撤销/重做历史步数(默认:10) |
| boolean | 大数据集的行虚拟化 |
| boolean | 时间轴(水平)虚拟化 |
| number | 统一行高(像素) |
| number | 任务栏高度(像素,必须≤ |
| number | 依赖连接线宽度 |
| string | 依赖连接线颜色 |