moveTask
Description
将任务移动到新位置
moveTask: (sid: string | number, tindex: number, parent?: string | number) => boolean | void
Parameters
sid- (required) string | number - 要移动的任务的 IDtindex- (required) number - 将要移动到的位置的索引
(分支中的索引)parent- (optional) string | number - 父级 ID。若指定,tindex 将引用在
'parent' 分支中的索引
Returns
result- (boolean | void) - 当操作因使用 onBeforeTaskMove 被取消时,返回false;否则返回undefined
Example
const tasks = {
data:[
{id:"p_1", text:"Project #1", start_date:"01-04-2023", duration:18,
open:true},
{id:"t_1", text:"Task #1", start_date:"02-04-2023", duration:8,
parent:"p_1"},
{id:"t_2", text:"Task #2", start_date:"11-04-2023", duration:8,
parent:"p_1"}
]
};
gantt.init("gantt_here");
gantt.parse(tasks);
gantt.moveTask("t_1", 1); /*!*/
//-> 这将把任务 "t_1" 移动到根级别
Related API
Need help?
Got a question about the documentation? Reach out to our technical support team for help and guidance. For custom component solutions, visit the Services page.