任务属性
本页面提供了任务对象可包含的所有属性 的完整列表。
关于 link 对象的全部属性,请参阅 Link Properties 文章。
必需属性
这些属性在客户端始终定义。当加载数据时,Gantt 期望任务对象中包含这些属性。如果缺失,Gantt 会自动添加它们。从已加载任务中移除这些属性会导致错误。
| 名称 | 类型 | 描述 |
|---|---|---|
| id | string | number | 任务的 id,如果未提供则自动生成 |
| start_date | Date | 任务的计划开始日期。如果省略,Gantt 会根据 end_date 和 duration 计算。 当设置 unscheduled: true 时,该属性变为可选。 |
| end_date | Date | 任务的计划完成日期。如果省略,Gantt 会根据 start_date 和 duration 计算。 当设置 unscheduled: true 时,该属性变为可选。 |
| duration | number | 任务的持续时间。如果省略,Gantt 会根据 start_date 和 end_date 计算。 |
可选属性
这些属性可以存在也可以不存在。当这些属性可用时,Gantt 的默认逻辑和模板会使用它们。
| 名称 | 类型 | 描述 |
|---|---|---|
| auto_scheduling | boolean | 指定 Gantt 是否对任务执行自动排程(true 或未指定)或不执行(false) |
| bar_height | number | 指定任务在时间轴中 DOM 元素的高度 |
| baselines | Baseline[] | 包含基线的数组 |
| calendar_id | number | string | 为任务分配自定义日历的 id。属性名取决于 calendar_property 选项 |
| color | string | 设置任务在时间轴中的颜色(应用于 gantt_task_line 元素的 background-color) |
| constraint_date | Date | 任务约束的日期,在启用 带有时间约束的自动排程 时添加。如果启用 auto_scheduling_compatibility,则不使用。 |
| constraint_type | string | 指定任务约束类型("asap"、"alap"、"snet"、"snlt"、"fnet"、"fnlt"、"mso"、"mfo")。在启用 带有时间约束的自动排程 时添加。如果启用 auto_scheduling_compatibility,则不使用。 |
| deadline | Date | 设置任务的截止日期。设置后,时间轴中会出现可视指示器。 |
| editable | boolean | 指定任务是否可以在只读 Gantt 图中编辑。属性名取决于 editable_property 选项 |
| group_id | string | number | 任务所属分组的 id。当任务通过 relation_property 在 groupBy() 方法中按对象属性分组时添加。 |
| hide_bar | boolean | 指定任务(type:"task")或里程碑(type:"milestone") 是否在时间轴中隐藏 |
| key | string | number | 分组键,当任务通过 relation_property 在 groupBy() 中按数组属性分组时添加。 也会添加到带有分组名称的任务(如按优先级分组时为 "High"、"Normal"、"Low")。查看示例。 |
| label | string | 分组标签,添加到带有分组名称的任务(如按优先级分组时为 "High"、"Normal"、"Low")。查看示例。 |
| open | boolean | 指示任务分支是否初始为展开状态以显示子任务。初始化后可通过 close() 和 open() 方法切换分支。 |
| parent | number | string | 父任务的 id。父任务不存在的任务不会被渲染。根任务 id 通过 root_id 配置设置。 |
| progress | number | 任务的进度值(0 到 1 之间) |
| progressColor | string | 设置任务进度条在时间轴中的颜色(应用于 gantt_task_progress 元素的 background-color) |
| readonly | boolean | 指示任务是否应为只读。属性名取决于 readonly_property 选项 |
| render | string | 控制子任务的显示方式。 值:"split" | ""。 如果设置为 "split",子任务会显示在同一行。当启用 open_split_tasks 属性时,仅当任务折叠时子任务才渲染为同一行。 |
| resource | Array <string> | 分配给任务的资源数组。在从 MS Project 或 Primavera 导入数据时添加 |
| rollup | boolean | 指 示任务(type:"task")或里程碑(type:"milestone") 是否应显示在父项目上。 |
| row_height | number | 设置任务所在行的高度 |
| target | string | 目标任务 id。该属性与 $drop_target 属性一致。 仅在启用 Data Processor 且任务更新并与服务器通信后,才会添加到任务对象中。 |
| text | any | 任务名称。可根据需要使用不同的属性名。 该属性用于 Gantt 的默认配置。 |
| textColor | string | 设置任务文本在时间轴中的颜色(应用于 gantt_task_line 元素的 color) |
| type | string | 任务类型。可用值在 types 对象中定义:
|
| unscheduled | boolean | 指示任务是否为未排程。默认情况下,未排程任务不会显示在时间轴中;而在网格中开始和结束日期会显示为空值。 |