split-task
PRO
The functionality is available in PRO Edition only
Description
Splits a task into multiple segmentsThe split-task action allows you to programmatically split a task. It adds one or more segments to a master task according to specific rules. This action only works if Gantt is initialized with splitTasks enabled.
Usage
"split-task": ({
id: string | number,
segmentIndex?: number,
}) => boolean | void;
Parameters
id– (required) the ID of the task to splitsegmentIndex– (optional) the index of the segment to split. If not provided, the first segment that lasts at least 2 duration units is split. If the task has no such segment, it isn't split | PRO feature
If the master task does not have any segments yet:
- Two new segments are created from the original task
If the master task already has segments:
- The specified segment (or the first segment that lasts at least 2 duration units if
segmentIndexis not provided) is split into two parts - The new segment is inserted after the original segment (or at the end if splitting the last segment)
Example
// Split a task with id 5 into two segments
api.exec("split-task", { id: 5 });
// Split the second segment of task with id 7
api.exec("split-task", { id: 7, segmentIndex: 1 });
Related articles: