syncfusion-angular-gantt-chart
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSyncfusion Angular Gantt Chart
Syncfusion Angular Gantt Chart
A comprehensive skill for implementing and configuring the Syncfusion Angular Gantt Chart component (). This covers everything from initial setup through advanced features like critical path, virtual scrolling, resource views, undo/redo, state persistence, localization, and export.
ejs-gantt这是一份关于实现和配置Syncfusion Angular Gantt Chart组件()的全面指南。内容涵盖从初始设置到关键路径、虚拟滚动、资源视图、撤销/重做、状态持久化、本地化和导出等高级功能的所有细节。
ejs-ganttWhen to Use This Skill
何时使用本指南
Use this skill when you need to:
- Install and set up the Angular Gantt Chart component
- Bind local or remote data to the Gantt chart
- Configure task scheduling modes (Auto/Manual/Custom)
- Define task dependencies and predecessor relationships
- Add, edit, or delete tasks (cell, dialog, taskbar editing)
- Assign and manage resources
- Configure timelines, zooming, and tier formats
- Customize taskbars, labels, and data markers
- Filter, sort, search, or select rows/cells
- Enable toolbar, context menu, or undo/redo
- Export to Excel or PDF
- Implement virtual scrolling or state persistence
- Apply localization, RTL layout, or timezone configuration
- Work with holidays, event markers, critical path, or baseline
当你需要以下功能时可使用本指南:
- 安装并设置Angular Gantt Chart组件
- 为甘特图绑定本地或远程数据
- 配置任务调度模式(自动/手动/自定义)
- 定义任务依赖关系和前置任务关联
- 添加、编辑或删除任务(单元格、对话框、任务栏编辑)
- 分配和管理资源
- 配置时间轴、缩放和层级格式
- 自定义任务栏、标签和数据标记
- 筛选、排序、搜索或选择行/单元格
- 启用工具栏、上下文菜单或撤销/重做功能
- 导出为Excel或PDF格式
- 实现虚拟滚动或状态持久化
- 应用本地化、RTL布局或时区配置
- 处理节假日、事件标记、关键路径或基准线
Documentation and Navigation Guide
文档与导航指南
Getting Started
入门指南
📄 Read: references/getting-started.md
- Installation via
ng add @syncfusion/ej2-angular-gantt - CSS imports for all themes (material3, bootstrap5, fluent2, tailwind3)
- Setting up Angular standalone component with and
importsproviders - Binding data with and
dataSource— self-referential vs hierarchicaltaskFields - Injecting feature services (EditService, FilterService, ToolbarService, etc.)
- Configuring timeline, toolbar, editing, filtering, sorting
- values:
gridLines|'Both'|'Horizontal'|'Vertical''None' - error handling for common configuration mistakes
actionFailure
📄 阅读: references/getting-started.md
- 通过完成安装
ng add @syncfusion/ej2-angular-gantt - 导入所有主题的CSS(material3、bootstrap5、fluent2、tailwind3)
- 使用和
imports设置Angular独立组件providers - 通过和
dataSource绑定数据——自引用与层级结构对比taskFields - 注入功能服务(EditService、FilterService、ToolbarService等)
- 配置时间轴、工具栏、编辑、筛选、排序功能
- 可选值:
gridLines|'Both'|'Horizontal'|'Vertical''None' - 错误处理,解决常见配置问题
actionFailure
Data Binding
数据绑定
📄 Read: references/data-binding.md
- Default pattern: Self-referential flat array with +
id(idMapping + parentIdMapping) — use this unless user explicitly asks for nested dataparentID - Hierarchical local data with array — only when user explicitly requests nested/tree structure
child - Decision table: when to use self-referential vs hierarchical
- Remote data binding with and adaptors (ODataV4, WebApiAdaptor, UrlAdaptor)
DataManager - Load-on-demand (virtual loading) with and
loadChildOnDemandhasChildMapping - Observable / RxJS data binding with pipe
async - Remote CRUD with ,
crudUrl,insertUrl,updateUrl,removeUrlbatchUrl - Common gotchas table (missing , wrong adaptor, parent date issues)
isPrimaryKey
📄 阅读: references/data-binding.md
- 默认模式: 带+
id的自引用扁平数组(idMapping + parentIdMapping)——除非用户明确要求嵌套数据,否则使用此模式parentID - 带数组的层级本地数据——仅当用户明确要求嵌套/树形结构时使用
child - 决策表:何时使用自引用 vs 层级结构
- 使用和适配器(ODataV4、WebApiAdaptor、UrlAdaptor)绑定远程数据
DataManager - 通过和
loadChildOnDemand实现按需加载(虚拟加载)hasChildMapping - 使用管道绑定Observable / RxJS数据
async - 通过、
crudUrl、insertUrl、updateUrl、removeUrl实现远程CRUDbatchUrl - 常见问题表(缺少、适配器错误、父级日期问题)
isPrimaryKey
Task Scheduling
任务调度
📄 Read: references/task-scheduling.md
- :
taskMode(default),'Auto','Manual'(per-task via boolean field)'Custom' - Auto mode: dates calculated from dependencies, working time, and holidays
- Manual mode: all dates fixed as-is in data source; use to still adjust on link
validateManualTasksOnLinking - Custom mode: per-task scheduling via mapped boolean field in data source
- Unscheduled tasks () — partial dates, floating bars
allowUnscheduledTasks - :
durationUnit|'Day'|'Hour''Minute' - Working days: array (default Mon–Fri);
workWeekmakes all 7 days workingincludeWeekend: true - Working hours: — array of
dayWorkingTimeranges (default 8–17); affects hour-based durations{ from, to } - Baseline dates (,
renderBaseline,baselineStartDate,baselineEndDate)baselineColor - Work scheduling (effort-driven) with field and
workworkUnit
📄 阅读: references/task-scheduling.md
- :
taskMode(默认)、'Auto'、'Manual'(通过布尔字段按任务设置)'Custom' - 自动模式:根据依赖关系、工作时间和节假日计算日期
- 手动模式:所有日期固定为数据源中的值;使用可在关联时仍调整日期
validateManualTasksOnLinking - 自定义模式:通过数据源中的映射布尔字段按任务设置调度方式
- 未调度任务()——部分日期、浮动任务栏
allowUnscheduledTasks - :
durationUnit|'Day'|'Hour''Minute' - 工作日: 数组(默认周一至周五);
workWeek设为7天全工作日includeWeekend: true - 工作时间: ——
dayWorkingTime范围数组(默认8–17点);影响基于小时的持续时间{ from, to } - 基准线日期(、
renderBaseline、baselineStartDate、baselineEndDate)baselineColor - 基于工作量的调度(工作量驱动),使用字段和
workworkUnit
Task Dependencies
任务依赖
📄 Read: references/task-dependencies.md
- Dependency types: (Finish-to-Start),
FS,SS,FF— format:SF,'2FS''3SS+1d' - Comma-separated multiple predecessors:
'2FS,3SS' - Predecessor lag/lead offsets with /
d/hunitsm - — sync offset values with actual positions on load
autoUpdatePredecessorOffset - — enable parent-child and cross-hierarchy dependencies
allowParentDependency - Editing via connector line drag when
editSettings.allowTaskbarEditing: true actionBegin— handle dependency conflictsrequestType: 'validateLinkedTask'- Programmatic: ,
addPredecessor(),removePredecessor()updateRecordById() - and
connectorLineWidthfor connector stylingconnectorLineBackground
📄 阅读: references/task-dependencies.md
- 依赖类型:(完成到开始)、
FS、SS、FF——格式:SF、'2FS''3SS+1d' - 多个前置任务用逗号分隔:
'2FS,3SS' - 前置任务滞后/提前量,单位为/
d/hm - ——加载时同步偏移值与实际位置
autoUpdatePredecessorOffset - ——启用父子任务和跨层级依赖
allowParentDependency - 当时,可通过拖动连接线编辑
editSettings.allowTaskbarEditing: true - 事件
actionBegin——处理依赖冲突requestType: 'validateLinkedTask' - 编程方式:、
addPredecessor()、removePredecessor()updateRecordById() - 连接线样式:和
connectorLineWidthconnectorLineBackground
Task Constraints
任务约束
📄 Read: references/task-constraints.md
- 8 constraint types: ASAP (0), ALAP (1), MSO (2), MFO (3), SNET (4), SNLT (5), FNET (6), FNLT (7)
- Map via (numeric) and
taskFields.constraintType(Date)taskFields.constraintDate - Constraints enforced only in Auto mode; stored-but-passive in Manual mode
- Conflicts with dependencies surface in event
actionBegin
📄 阅读: references/task-constraints.md
- 8种约束类型:ASAP(0)、ALAP(1)、MSO(2)、MFO(3)、SNET(4)、SNLT(5)、FNET(6)、FNLT(7)
- 通过(数值)和
taskFields.constraintType(日期)映射taskFields.constraintDate - 约束仅在自动模式下生效;手动模式下仅存储但不生效
- 依赖冲突会在事件中体现
actionBegin
Managing Tasks
任务管理
📄 Read: references/managing-tasks.md
- :
editSettings,allowEditing,allowAdding,allowDeleting,allowTaskbarEditing(mode|'Auto')'Dialog' - Cell editing with per column:
editType,'numericedit','defaultedit','dropdownedit','booleanedit''datepickeredit' - Dialog editing with custom tab configuration (,
addDialogFields)editDialogFields - Programmatic: ,
addRecord(),updateRecordById(),deleteRecord(),openAddDialog()openEditDialog(id) - Expand/collapse: ,
expandAll(),collapseAll(),expandByID(id); events:collapseByID(id),expanding,expanded,collapsingcollapsed - Validation via event (
actionBeginto block)args.cancel = true - Server CRUD via +
actionCompleteinspectionrequestType - Indent / outdent hierarchy changes via toolbar or /
indent()methodsoutdent()
📄 阅读: references/managing-tasks.md
- :
editSettings、allowEditing、allowAdding、allowDeleting、allowTaskbarEditing(mode|'Auto')'Dialog' - 按列设置实现单元格编辑:
editType、'numericedit'、'defaultedit'、'dropdownedit'、'booleanedit''datepickeredit' - 自定义对话框编辑选项卡配置(、
addDialogFields)editDialogFields - 编程方式:、
addRecord()、updateRecordById()、deleteRecord()、openAddDialog()openEditDialog(id) - 展开/折叠:、
expandAll()、collapseAll()、expandByID(id);事件:collapseByID(id)、expanding、expanded、collapsingcollapsed - 通过事件实现验证(
actionBegin可阻止操作)args.cancel = true - 通过+ 检查
actionComplete实现服务端CRUDrequestType - 通过工具栏或/
indent()方法调整层级缩进/取消缩进outdent()
Splitting and Merging Tasks
任务拆分与合并
📄 Read: references/splitting-and-merging.md
- for hierarchical data;
taskFields.segmentsfor self-referential datataskFields.segmentId - Split at load time or dynamically via dialog Segments tab or context menu
SplitTask - Merge via context menu or by dragging segments together
MergeTask - with
onTaskbarClickto detect which segment was clickedsegmentIndex - Limitations: no splits on parent/milestone tasks; incompatible with multi-taskbar resource view
📄 阅读: references/splitting-and-merging.md
- 层级数据使用;自引用数据使用
taskFields.segmentstaskFields.segmentId - 加载时拆分或通过对话框Segments选项卡/上下文菜单动态拆分
SplitTask - 通过上下文菜单或拖动分段合并任务
MergeTask - 事件结合
onTaskbarClick检测点击的分段segmentIndex - 限制:父任务/里程碑任务无法拆分;与多任务栏资源视图不兼容
Resources
资源管理
📄 Read: references/resources.md
- (data) +
resources(field mapping:resourceFields,id,name,unit)group - to link resources to tasks
taskFields.resourceInfo - Resource view mode () with row-per-resource display
viewType: 'ResourceView' - — stacked taskbars for over-allocated resources
showOverAllocationAsMultiTaskbar - Work-based scheduling: field,
work(taskType,'FixedWork','FixedDuration')'FixedUnit' - Work unit: |
workUnit: 'Hour'|'Day''Minute'
📄 阅读: references/resources.md
- (数据)+
resources(字段映射:resourceFields、id、name、unit)group - 将资源与任务关联
taskFields.resourceInfo - 资源视图模式(),按资源分行显示
viewType: 'ResourceView' - ——为过度分配的资源显示堆叠任务栏
showOverAllocationAsMultiTaskbar - 基于工作量的调度:字段、
work(taskType、'FixedWork'、'FixedDuration')'FixedUnit' - 工作量单位:|
workUnit: 'Hour'|'Day''Minute'
Columns
列配置
📄 Read: references/columns.md
- Column ,
field,headerText,width,format,type,templateheaderTemplate - Column reordering (), resizing (
allowReordering)allowResizing - Frozen columns (|
freeze: 'Left') — requires'Right'FreezeService - Column spanning via
queryCellInfo - for tree expand/collapse column
treeColumnIndex - WBS (Work Breakdown Structure) column with
columnType: 'WBS' - Column menu () — sort, filter, auto-fit, column chooser
showColumnMenu - requirement for CRUD operations
isPrimaryKey
📄 阅读: references/columns.md
- 列属性:、
field、headerText、width、format、type、templateheaderTemplate - 列重排()、调整大小(
allowReordering)allowResizing - 冻结列(|
freeze: 'Left')——需要'Right'FreezeService - 通过实现列合并
queryCellInfo - 设置树形展开/折叠列
treeColumnIndex - WBS(工作分解结构)列,设置
columnType: 'WBS' - 列菜单()——排序、筛选、自动适配、列选择器
showColumnMenu - CRUD操作需要
isPrimaryKey
Timeline
时间轴配置
📄 Read: references/timeline.md
- configuration
timelineSettings - Top tier and bottom tier customization
- Timeline view modes (day/week/month/year)
- Formatter function with parameters
(date, format, tier, mode) - Timeline cell width ()
timelineUnitSize - Custom date formats
- and
projectStartDateprojectEndDate - Timeline view window (/
viewStartDate)viewEndDate - Week start day ()
weekStartDay - Automatic timescale update ()
updateTimescaleView - Weekend highlighting ()
timelineSettings.showWeekend - Timeline cells tooltip ()
showTooltip - Navigate timeline (/
previousTimeSpan())nextTimeSpan() - Zooming in and out
📄 阅读: references/timeline.md
- 配置
timelineSettings - 自定义顶层和底层时间层级
- 时间轴视图模式(日/周/月/年)
- 格式化函数,参数为
(date, format, tier, mode) - 时间轴单元格宽度()
timelineUnitSize - 自定义日期格式
- 和
projectStartDateprojectEndDate - 时间轴视图窗口(/
viewStartDate)viewEndDate - 周起始日()
weekStartDay - 自动更新时间刻度()
updateTimescaleView - 突出显示周末()
timelineSettings.showWeekend - 时间轴单元格提示()
showTooltip - 时间轴导航(/
previousTimeSpan())nextTimeSpan() - 缩放功能
Taskbar
任务栏配置
📄 Read: references/taskbar.md
- ,
taskbarTemplate,parentTaskbarTemplate— full custom templatesmilestoneTemplate - :
labelSettings,leftLabel,rightLabel(field names or templates)taskLabel - — dynamic styling:
queryTaskbarInfo,taskbarBgColor,progressBarBgColortaskbarBorderColor - / data markers on individual tasks:
indicators,date,iconClass,labeltooltip - Tooltip customization via template
tooltipSettings.taskbar - ,
taskbarHeight,taskbarCornerRadiusallowTaskbarDragAndDrop
📄 阅读: references/taskbar.md
- 、
taskbarTemplate、parentTaskbarTemplate——完全自定义模板milestoneTemplate - :
labelSettings、leftLabel、rightLabel(字段名或模板)taskLabel - ——动态样式:
queryTaskbarInfo、taskbarBgColor、progressBarBgColortaskbarBorderColor - 单个任务的标记/数据标记:、
date、iconClass、labeltooltip - 通过模板自定义提示
tooltipSettings.taskbar - 、
taskbarHeight、taskbarCornerRadiusallowTaskbarDragAndDrop
Filtering and Searching
筛选与搜索
📄 Read: references/filtering-and-searching.md
- +
allowFiltering: true— menu and Excel filter typesFilterService - :
filterSettings.type(default) |'Menu''Excel' - :
filterSettings.hierarchyMode|'Parent'|'Child'|'Both''None' - Initial filter on load via array
filterSettings.columns - Searching: +
allowSearching: truein toolbar'Search' - :
searchSettings,fields,operatorignoreCase - Programmatic: ,
filterByColumn(),clearFiltering()search()
📄 阅读: references/filtering-and-searching.md
- +
allowFiltering: true——菜单和Excel筛选类型FilterService - :
filterSettings.type(默认) |'Menu''Excel' - :
filterSettings.hierarchyMode|'Parent'|'Child'|'Both''None' - 加载时通过数组设置初始筛选
filterSettings.columns - 搜索:+ 工具栏中的
allowSearching: true'Search' - :
searchSettings、fields、operatorignoreCase - 编程方式:、
filterByColumn()、clearFiltering()search()
Sorting
排序
📄 Read: references/sorting.md
- +
allowSorting: true— click column headers to sortSortService - Disable per column:
{ field: 'TaskID', allowSorting: false } - Multi-column sort: Ctrl+click additional headers; Shift+click to remove
- Initial sort on load via array
sortSettings.columns - Programmatic: ,
sortColumn(),removeSortColumn()clearSorting()
📄 阅读: references/sorting.md
- +
allowSorting: true——点击列标题排序SortService - 按列禁用排序:
{ field: 'TaskID', allowSorting: false } - 多列排序:Ctrl+点击其他标题;Shift+点击取消排序
- 加载时通过数组设置初始排序
sortSettings.columns - 编程方式:、
sortColumn()、removeSortColumn()clearSorting()
Rows
行配置
📄 Read: references/rows.md
- /
rowDataBound— dynamic row/cell stylingqueryCellInfo - — uniform row height in pixels (must exceed
rowHeight)taskbarHeight - — alternate row background (default
enableAltRow)true - — fully custom row layout in TreeGrid pane
rowTemplate - with
queryRowInfo— vertical cell spanningrowSpan - — drag rows to reorder/reparent;
allowRowDragAndDrop/rowDragStartHelpereventsrowDrop
📄 阅读: references/rows.md
- /
rowDataBound——动态行/单元格样式queryCellInfo - ——统一行高(像素值,必须大于
rowHeight)taskbarHeight - ——交替行背景色(默认
enableAltRow)true - ——TreeGrid面板中完全自定义行布局
rowTemplate - 结合
queryRowInfo——垂直单元格合并rowSpan - ——拖动行重新排序/调整父级;
allowRowDragAndDrop/rowDragStartHelper事件rowDrop
Selection
选择功能
📄 Read: references/selection.md
- +
allowSelection: true— required for any selection featureSelectionService - :
selectionSettings.mode(default) |'Row'|'Cell''Both' - :
selectionSettings.type(default) |'Single'(Ctrl+click for multi-select)'Multiple' - — click to deselect already-selected row
selectionSettings.enableToggle - Cell selection modes: |
'Flow'|'Box''BoxWithBorder' - Programmatic: ,
selectRow(),selectRows(),selectCell(),clearSelection()getSelectedRecords()
📄 阅读: references/selection.md
- +
allowSelection: true——任何选择功能都需要此配置SelectionService - :
selectionSettings.mode(默认) |'Row'|'Cell''Both' - :
selectionSettings.type(默认) |'Single'(Ctrl+点击多选)'Multiple' - ——点击取消已选中行
selectionSettings.enableToggle - 单元格选择模式:|
'Flow'|'Box''BoxWithBorder' - 编程方式:、
selectRow()、selectRows()、selectCell()、clearSelection()getSelectedRecords()
Scrolling
滚动配置
📄 Read: references/scrolling.md
- +
enableVirtualization: true— DOM virtualization for large datasetsVirtualScrollService - — virtualize timeline columns independently
enableTimelineVirtualization - Splitter: (percentage string or pixel value),
splitterSettings.position,columnIndex(view|'Default'|'Grid')'Chart' - Programmatic: ,
scrollToDate('04/02/2024')scrollToTaskbar(taskId) - Virtual scroll limitations: row/column templates, grouping, and some aggregate features not supported
📄 阅读: references/scrolling.md
- +
enableVirtualization: true——大数据集的DOM虚拟化VirtualScrollService - ——独立虚拟化时间轴列
enableTimelineVirtualization - 拆分器:(百分比字符串或像素值)、
splitterSettings.position、columnIndex(view|'Default'|'Grid')'Chart' - 编程方式:、
scrollToDate('04/02/2024')scrollToTaskbar(taskId) - 虚拟滚动限制:不支持行/列模板、分组和部分聚合功能
Toolbar
工具栏配置
📄 Read: references/toolbar.md
- required; set
ToolbarServiceas string array or mixedtoolbararrayItemModel - Built-in items: ,
'Add','Edit','Delete','Update','Cancel','ExpandAll','CollapseAll','Search','Indent','Outdent','ZoomIn','ZoomOut','ZoomToFit','ExcelExport','CsvExport','PdfExport','CriticalPath','Undo','Redo','SplitTask','MergeTask''ColumnChooser' - Custom items via :
ItemModel,text,id,prefixIcon,aligntooltipText - for visual dividers
{ type: 'Separator' } - event — use
toolbarClickto identify clicked item (format:args.item.id)'{ganttId}_{itemId}' - Enable/disable programmatically: /
enableToolbarItems()disableToolbarItems()
📄 阅读: references/toolbar.md
- 需要;
ToolbarService设为字符串数组或混合toolbar数组ItemModel - 内置项:、
'Add'、'Edit'、'Delete'、'Update'、'Cancel'、'ExpandAll'、'CollapseAll'、'Search'、'Indent'、'Outdent'、'ZoomIn'、'ZoomOut'、'ZoomToFit'、'ExcelExport'、'CsvExport'、'PdfExport'、'CriticalPath'、'Undo'、'Redo'、'SplitTask'、'MergeTask''ColumnChooser' - 通过自定义项:
ItemModel、text、id、prefixIcon、aligntooltipText - 设置视觉分隔符
{ type: 'Separator' } - 事件——通过
toolbarClick识别点击项(格式:args.item.id)'{ganttId}_{itemId}' - 编程方式启用/禁用:/
enableToolbarItems()disableToolbarItems()
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: ,
load,created,dataBounddestroyed - Edit lifecycle: (cancel with
actionBegin),args.cancel = true,actionCompleteactionFailure - Taskbar: ,
taskbarEditing,taskbarEdited,onTaskbarClickqueryTaskbarInfo - Row/cell: ,
rowDataBound,queryCellInfo,queryRowInfo,rowSelected,rowDeselectedcellSelected - Expand/collapse: ,
expanding,expanded,collapsingcollapsed - Export: ,
beforeExcelExport,excelExportComplete,beforePdfExport,pdfExportCompletepdfQueryTaskbarInfo - — open custom edit on double click
recordDoubleClick
📄 阅读: references/events.md
- 生命周期:、
load、created、dataBounddestroyed - 编辑生命周期:(
actionBegin可取消)、args.cancel = true、actionCompleteactionFailure - 任务栏:、
taskbarEditing、taskbarEdited、onTaskbarClickqueryTaskbarInfo - 行/单元格:、
rowDataBound、queryCellInfo、queryRowInfo、rowSelected、rowDeselectedcellSelected - 展开/折叠:、
expanding、expanded、collapsingcollapsed - 导出:、
beforeExcelExport、excelExportComplete、beforePdfExport、pdfExportCompletepdfQueryTaskbarInfo - ——双击打开自定义编辑
recordDoubleClick
Context Menu
上下文菜单
📄 Read: references/context-menu.md
- +
enableContextMenu: true— right-click on rows or headerContextMenuService - Default items include: ,
'AutoFitAll','AutoFit','SortAscending','SortDescending','Add','Edit','Delete','Save','Cancel','Indent','Outdent','TaskInformation','SplitTask''MergeTask' - Custom items via :
ContextMenuItemModel,text,id,iconCss(row/header)target - — dynamically hide/show items per row
contextMenuOpen - — handle item selection
contextMenuClick
📄 阅读: references/context-menu.md
- +
enableContextMenu: true——右键点击行或标题ContextMenuService - 默认项包括:、
'AutoFitAll'、'AutoFit'、'SortAscending'、'SortDescending'、'Add'、'Edit'、'Delete'、'Save'、'Cancel'、'Indent'、'Outdent'、'TaskInformation'、'SplitTask''MergeTask' - 通过自定义项:
ContextMenuItemModel、text、id、iconCss(行/标题)target - ——按行动态显示/隐藏项
contextMenuOpen - ——处理项选择
contextMenuClick
Holidays and Event Markers
节假日与事件标记
📄 Read: references/holidays-and-markers.md
- required for both holidays and event markers
DayMarkersService - : array of
holidays— non-working days that extend task durations{ from, to?, label, cssClass } - : array of
eventMarkers— full-height vertical lines at specific dates{ day, label, cssClass, top? } - Custom styling per type via + CSS targeting
cssClass/.e-gantt-event-marker.e-span-label - property staggers overlapping markers at the same date
top
📄 阅读: references/holidays-and-markers.md
- 节假日和事件标记都需要
DayMarkersService - :
holidays数组——非工作日,会延长任务持续时间{ from, to?, label, cssClass } - :
eventMarkers数组——特定日期的全高垂直线{ day, label, cssClass, top? } - 通过+ CSS定位
cssClass/.e-gantt-event-marker实现自定义样式.e-span-label - 属性可在同一日期错开重叠标记
top
Critical Path
关键路径
📄 Read: references/critical-path.md
- +
enableCriticalPath: true— highlights zero/negative-slack tasks in redCriticalPathService - toolbar item — user toggle button
'CriticalPath' - — returns array of
getCriticalTasks()objects withIGanttDatavalueslack - +
queryTaskbarInfo— conditional per-task coloringganttProperties.isCritical - CSS overrides: ,
.e-critical-path-container.e-critical-connector-line - Rules: completed tasks (100%) excluded; parent/child criticality independent; auto-recalculates on any change
📄 阅读: references/critical-path.md
- +
enableCriticalPath: true——将零/负松弛任务高亮为红色CriticalPathService - 工具栏项——用户切换按钮
'CriticalPath' - ——返回带
getCriticalTasks()值的slack对象数组IGanttData - +
queryTaskbarInfo——按任务条件着色ganttProperties.isCritical - CSS覆盖:、
.e-critical-path-container.e-critical-connector-line - 规则:已完成任务(100%)排除;父/子任务关键状态独立;任何更改时自动重新计算
Export (Excel and PDF)
导出(Excel和PDF)
📄 Read: references/export.md
- Excel: +
allowExcelExport: true; callExcelExportService/excelExport()csvExport() - PDF: +
allowPdfExport: true; callPdfExportServicepdfExport() - :
ExcelExportProperties,fileName,dataSource,includeHiddenColumn,headerfooter - :
PdfExportProperties,fileName,pageOrientation,pageSize,fitToWidthSettings,ganttStyletheme - PDF header/footer content types: ,
Text,Line,PageNumberImage - Single-page export:
fitToWidthSettings.isFitToWidth: true - Blob export: → blob available in
pdfExport({}, true)eventpdfExportComplete - Multi-Gantt export to one PDF via chained with
pdfExport()multipleExport - — per-taskbar colors in PDF output
pdfQueryTaskbarInfo
📄 阅读: references/export.md
- Excel:+
allowExcelExport: true;调用ExcelExportService/excelExport()csvExport() - PDF:+
allowPdfExport: true;调用PdfExportServicepdfExport() - :
ExcelExportProperties、fileName、dataSource、includeHiddenColumn、headerfooter - :
PdfExportProperties、fileName、pageOrientation、pageSize、fitToWidthSettings、ganttStyletheme - PDF页眉/页脚内容类型:、
Text、Line、PageNumberImage - 单页导出:
fitToWidthSettings.isFitToWidth: true - Blob导出:→ 在
pdfExport({}, true)事件中获取blobpdfExportComplete - 多甘特图导出到单个PDF:通过链式调用
multipleExportpdfExport() - ——PDF输出中按任务栏着色
pdfQueryTaskbarInfo
Undo / Redo
撤销/重做
📄 Read: references/undo-redo.md
- +
enableUndoRedo: true— up to 10 steps by defaultUndoRedoService - array — choose which action types are tracked (18 supported actions)
undoRedoActions - — configure history depth
undoRedoStepsCount - Keyboard: /
Ctrl+Z; programmatic:Ctrl+Y/undo()redo() - /
'Undo'toolbar items auto-disable when history is exhausted'Redo'
📄 阅读: references/undo-redo.md
- +
enableUndoRedo: true——默认最多10步UndoRedoService - 数组——选择要跟踪的操作类型(支持18种操作)
undoRedoActions - ——配置历史记录深度
undoRedoStepsCount - 键盘快捷键:/
Ctrl+Z;编程方式:Ctrl+Y/undo()redo() - 历史记录耗尽时,/
'Undo'工具栏项自动禁用'Redo'
State Persistence
状态持久化
📄 Read: references/state-persistence.md
- — saves filter/sort/column state to
enablePersistence: trueunder keylocalStorage'{id}gantt' - Requires unique on
idelement<ejs-gantt> - Reset methods: , remove localStorage key manually, or set new
clearStorage()id - Immutable mode () — only re-renders changed rows for large-dataset performance
enableImmutableMode - Loading animation: —
loadingIndicator.indicatorType(default) |'Spinner''Shimmer' - Manual spinner: /
showSpinner()hideSpinner()
📄 阅读: references/state-persistence.md
- ——将筛选/排序/列状态保存到
enablePersistence: true,键为localStorage'{id}gantt' - 元素需要唯一
<ejs-gantt>id - 重置方法:、手动删除localStorage键或设置新
clearStorage()id - 不可变模式()——数据刷新时仅重新渲染更改的行,提升大数据集性能
enableImmutableMode - 加载动画:——
loadingIndicator.indicatorType(默认) |'Spinner''Shimmer' - 手动控制加载动画:/
showSpinner()hideSpinner()
Localization, RTL and Formatting
本地化、RTL与格式化
📄 Read: references/localization-rtl.md
- property +
locale+setCulture()— translate all Gantt UI stringsL10n.load() - Full locale key reference for the namespace
'gantt' - RTL: +
[enableRtl]="true"— reverses layout directionlocale="ar" - — IANA timezone string (e.g.
timezone,'America/New_York') for consistent cross-region dates'UTC' - Column date formatting: string or
format{ type: 'date', skeleton: 'yMd' } - Column number formatting: ,
'N2','C2'etc.'P1'
📄 阅读: references/localization-rtl.md
- 属性 +
locale+setCulture()——翻译所有甘特图UI字符串L10n.load() - 命名空间的完整本地化键参考
'gantt' - RTL:+
[enableRtl]="true"——反转布局方向locale="ar" - ——IANA时区字符串(如
timezone、'America/New_York'),确保跨区域日期一致'UTC' - 列日期格式化:字符串或
format{ type: 'date', skeleton: 'yMd' } - 列数字格式化:、
'N2'、'C2'等'P1'
Quick Start Example
快速入门示例
typescript
import { Component } from '@angular/core';
import { GanttModule, EditService, SortService, FilterService, ToolbarService, SelectionService } from '@syncfusion/ej2-angular-gantt';
@Component({
imports: [GanttModule],
standalone: true,
providers: [EditService, SortService, FilterService, ToolbarService, SelectionService],
selector: 'app-root',
template: `
<ejs-gantt
[dataSource]="data"
[taskFields]="taskFields"
[height]="'450px'"
[toolbar]="toolbar"
[allowFiltering]="true"
[allowSorting]="true"
[editSettings]="editSettings">
</ejs-gantt>
`
})
export class AppComponent {
// Default: self-referential data (flat array with id + parentID)
// Use hierarchical (child array) only if user explicitly requests it
public data: object[] = [
{ TaskID: 1, TaskName: 'Project Initiation', StartDate: new Date('04/02/2024'), Duration: 5, Progress: 0, ParentID: null },
{ TaskID: 2, TaskName: 'Identify Site location', StartDate: new Date('04/02/2024'), Duration: 4, Progress: 50, ParentID: 1 },
{ TaskID: 3, TaskName: 'Perform Soil test', StartDate: new Date('04/02/2024'), Duration: 4, Progress: 50, ParentID: 1 },
{ TaskID: 4, TaskName: 'Soil test approval', StartDate: new Date('04/02/2024'), Duration: 4, Progress: 50, ParentID: 1, Predecessor: '3FS' }
];
public taskFields: object = {
id: 'TaskID', // idMapping
name: 'TaskName',
startDate: 'StartDate',
duration: 'Duration',
progress: 'Progress',
dependency: 'Predecessor',
parentID: 'ParentID' // parentIdMapping — null = root task
};
public toolbar: string[] = ['Add', 'Edit', 'Delete', 'ExpandAll', 'CollapseAll', 'Search'];
public editSettings: object = { allowEditing: true, allowAdding: true, allowDeleting: true, allowTaskbarEditing: true };
}typescript
import { Component } from '@angular/core';
import { GanttModule, EditService, SortService, FilterService, ToolbarService, SelectionService } from '@syncfusion/ej2-angular-gantt';
@Component({
imports: [GanttModule],
standalone: true,
providers: [EditService, SortService, FilterService, ToolbarService, SelectionService],
selector: 'app-root',
template: `
<ejs-gantt
[dataSource]="data"
[taskFields]="taskFields"
[height]="'450px'"
[toolbar]="toolbar"
[allowFiltering]="true"
[allowSorting]="true"
[editSettings]="editSettings">
</ejs-gantt>
`
})
export class AppComponent {
// 默认:自引用数据(带id + parentID的扁平数组)
// 仅当用户明确要求时才使用层级结构(child数组)
public data: object[] = [
{ TaskID: 1, TaskName: '项目启动', StartDate: new Date('04/02/2024'), Duration: 5, Progress: 0, ParentID: null },
{ TaskID: 2, TaskName: '确定场地位置', StartDate: new Date('04/02/2024'), Duration: 4, Progress: 50, ParentID: 1 },
{ TaskID: 3, TaskName: '进行土壤测试', StartDate: new Date('04/02/2024'), Duration: 4, Progress: 50, ParentID: 1 },
{ TaskID: 4, TaskName: '土壤测试审批', StartDate: new Date('04/02/2024'), Duration: 4, Progress: 50, ParentID: 1, Predecessor: '3FS' }
];
public taskFields: object = {
id: 'TaskID', // idMapping
name: 'TaskName',
startDate: 'StartDate',
duration: 'Duration',
progress: 'Progress',
dependency: 'Predecessor',
parentID: 'ParentID' // parentIdMapping — null = 根任务
};
public toolbar: string[] = ['Add', 'Edit', 'Delete', 'ExpandAll', 'CollapseAll', 'Search'];
public editSettings: object = { allowEditing: true, allowAdding: true, allowDeleting: true, allowTaskbarEditing: true };
}Common Patterns
常见模式
When user needs task editing
当用户需要任务编辑功能
→ Set , inject
→ Use for cell editing, for dialog
editSettings.allowEditing: trueEditServicemode: 'Auto'mode: 'Dialog'→ 设置,注入
→ 使用实现单元格编辑,实现对话框编辑
editSettings.allowEditing: trueEditServicemode: 'Auto'mode: 'Dialog'When user needs large dataset performance
当用户需要大数据集性能优化
→ Read — enable +
references/scrolling.mdenableVirtualization: trueVirtualScrollService→ 阅读——启用 +
references/scrolling.mdenableVirtualization: trueVirtualScrollServiceWhen user needs to export data
当用户需要导出数据
→ Read — inject or
references/export.mdExcelExportServicePdfExportService→ 阅读——注入或
references/export.mdExcelExportServicePdfExportServiceWhen user needs resource management
当用户需要资源管理
→ Read — configure +
references/resources.mdresourcesresourceFields→ 阅读——配置 +
references/resources.mdresourcesresourceFieldsWhen user needs undo/redo
当用户需要撤销/重做功能
→ Read — inject , set
references/undo-redo.mdUndoRedoServiceenableUndoRedo: true→ 阅读——注入,设置
references/undo-redo.mdUndoRedoServiceenableUndoRedo: trueWhen user needs localization or RTL
当用户需要本地化或RTL
→ Read — call before bootstrap, set and
references/localization-rtl.mdL10n.load()localeenableRtl→ 阅读——在bootstrap前调用,设置和
references/localization-rtl.mdL10n.load()localeenableRtlWhen user needs state persistence
当用户需要状态持久化
→ Read — set and unique
references/state-persistence.mdenablePersistence: trueid→ 阅读——设置和唯一
references/state-persistence.mdenablePersistence: trueidWhen user needs split/segment tasks
当用户需要拆分/分段任务
→ Read — map , inject
references/splitting-and-merging.mdtaskFields.segmentsEditService→ 阅读——映射,注入
references/splitting-and-merging.mdtaskFields.segmentsEditServiceKey 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 | |
| 功能 | 需注入的服务 |
|---|---|
| 编辑(添加/编辑/删除/任务栏拖动) | |
| 筛选 | |
| 排序 | |
| 工具栏 | |
| 选择 | |
| 日期标记 / 节假日 / 事件标记 | |
| 关键路径 | |
| Excel / CSV导出 | |
| PDF导出 | |
| 撤销/重做 | |
| 列菜单 | |
| 上下文菜单 | |
| 虚拟滚动 | |
| 行拖动 | |
| 列重排 | |
| 冻结列 | |
| 列调整大小 | |
Key Props Reference
核心属性参考
| Property | Type | Default | Description |
|---|---|---|---|
| | | Task data — self-referential (flat) or hierarchical |
| | — | Maps data fields to Gantt task properties |
| | | Component height (e.g. |
| | | Scheduling mode: |
| | — | Enable add/edit/delete/taskbar editing and edit mode |
| | — | Toolbar buttons — requires |
| | | Enable column filter menus — requires |
| | — | |
| | | Enable column sorting — requires |
| | — | |
| | | Enable row/cell selection — requires |
| | — | |
| | | Highlight critical path — requires |
| | | Enable undo/redo — requires |
| | (all actions) | Which action types to track in history |
| | | Maximum undo/redo history depth |
| | | Persist filter/sort/column state to |
| | | Re-render only changed rows on data refresh |
| | | Enable Excel export — requires |
| | | Enable PDF export — requires |
| | | Enable right-click context menu — requires |
| | (defaults) | Context menu items |
| | | DOM virtualization for large datasets — requires |
| | | Virtualize timeline columns |
| | | Show baseline bars alongside current taskbars |
| | | Baseline bar color |
| | | Allow tasks missing start/end/duration |
| | | Adjust manual task dates when dependency links change |
| | | Allow dependencies between parent/child tasks |
| | | Sync predecessor offsets with actual positions on load |
| | | Shade weekend columns in timeline |
| | | Grid lines: |
| | | Height of each row in pixels |
| | | Alternate row background color |
| | | Drag rows to reorder or reparent |
| | | Column header context menu — requires |
| | — | |
| | — | Shortcut: |
| | (from data) | Fix timeline start bound |
| | (from data) | Fix timeline end bound |
| | | Non-working days with labels — requires |
| | | Vertical marker lines — requires |
| | — | Resource data array |
| | — | Maps resource |
| | | Culture code for localization (e.g. |
| | | Right-to-left layout |
| | (browser) | IANA timezone (e.g. |
| | | Default duration unit: |
| | | Work scheduling unit: |
| | Mon–Fri | Working days: |
| | | Treat all 7 days as working days |
| | | Working hour ranges per day: |
| | | Global date display format for all date columns |
| | — | |
| | — | |
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| | | 任务数据——自引用(扁平)或层级结构 |
| | — | 将数据字段映射到甘特图任务属性 |
| | | 组件高度(如 |
| | | 调度模式: |
| | — | 启用添加/编辑/删除/任务栏编辑及编辑模式 |
| | — | 工具栏按钮——需要 |
| | | 启用列筛选菜单——需要 |
| | — | |
| | | 启用列排序——需要 |
| | — | |
| | | 启用行/单元格选择——需要 |
| | — | |
| | | 高亮关键路径——需要 |
| | | 启用撤销/重做——需要 |
| | (所有操作) | 跟踪历史记录的操作类型 |
| | | 撤销/重做历史记录的最大深度 |
| | | 将筛选/排序/列状态持久化到 |
| | | 数据刷新时仅重新渲染更改的行 |
| | | 启用Excel导出——需要 |
| | | 启用PDF导出——需要 |
| | | 启用右键上下文菜单——需要 |
| | (默认项) | 上下文菜单项 |
| | | 大数据集的DOM虚拟化——需要 |
| | | 虚拟化时间轴列 |
| | | 在当前任务栏旁显示基准线 |
| | | 基准线颜色 |
| | | 允许缺少开始/结束/持续时间的任务 |
| | | 依赖关系变化时调整手动任务日期 |
| | | 允许父子任务间的依赖关系 |
| | | 加载时同步前置任务偏移值与实际位置 |
| | | 为时间轴中的周末列添加阴影 |
| | | 网格线: |
| | | 每行高度(像素) |
| | | 交替行背景色 |
| | | 拖动行重新排序或调整父级 |
| | | 列标题上下文菜单——需要 |
| | — | |
| | — | 快捷设置: |
| | (来自数据) | 固定时间轴起始边界 |
| | (来自数据) | |
| | | 带标签的非工作日——需要 |
| | | 垂直标记线——需要 |
| | — | 资源数据数组 |
| | — | 映射资源 |
| | | 本地化文化代码(如 |
| | | 从右到左布局 |
| | (浏览器时区) | IANA时区(如 |
| | | 默认持续时间单位: |
| | | 工作量调度单位: |
| | 周一至周五 | 工作日: |
| | | 将7天设为工作日 |
| | | 每日工作时间范围: |
| | | 所有日期列的全局日期显示格式 |
| | — | TreeGrid/图表拆分的 |
| | — | |