onBeforeRowDragEnd

当用户在grid中拖放一行时触发。

boolean onBeforeRowDragEnd(string|number sid,string|number parent,number tindex);
sidstring|number被移动任务的ID
parentstring|number父节点ID。详细说明见下文
tindexnumber任务被移动前的位置索引
(整个树中的索引)。如果指定,tindex对应于“parent”分支中的索引。详见下文
boolean决定默认事件动作是否继续执行(true)或被取消(false

Example

gantt.attachEvent("onBeforeRowDragEnd", function(id, parent, tindex){
    const task = gantt.getTask(id);
    if(task.parent != parent)
        return false;
    return true;
});

Related samples

Details

当使用鼠标在左侧grid中移动任务时触发此事件,前提是启用了order_branch设置。如果关闭了分支重新排序功能,则不会触发此事件。

  • 事件触发时,任务已经被移动到新位置,但更改仍可撤销
  • 事件可以被阻止。返回false会取消操作并将任务返回到原始位置
  • 处理函数会接收到任务的原始位置(父节点和索引)作为参数
  • 目标位置可以通过任务对象的task.parentgantt.getGlobalTaskIndex(taskId)访问
  • parenttindex参数根据order_branch模式不同而不同:
    • 在标准模式("true")下:
      • parent参数指任务的原始父节点(移动前)
      • tindex参数指原始局部索引
    • 在“marker”模式下:
      • parent参数指任务的新父节点
      • tindex参数指新局部索引
See also
Back to top