split-task
Description
The 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,
};
Parameters
id– (required) the ID of the task to splitsegmentIndex–PRO feature(optional) the index of the segment to split. If not provided, the last segment of the task is split
If the master task does not have any segments yet:
- Two equal segments are created from the original task
If the master task already has segments:
- The specified segment (or the last segment if
segmentIndexis not provided) is split into two equal 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 });