这篇文章给大家讲解dhtmlxGantt如何实现重新排序。
dhtmlxGantt 提供了 2 种方式在网格中重新排序任务:
- 拖放。
- 排序。
方法是可选的。默认情况下,这两种模式都被禁用。
要启用拖放重新排序,请使用order_branch选项:
gantt.config.order_branch = true; gantt.init("gantt_here");
1、在整个甘特结构中拖放
order_branch选项允许在同一树级别内拖动任务。
还可以启用可以在整个甘特图中重新排序任务的模式。这意味着一个任务可以替换任何树级别的另一个任务。要使用这种类型的任务重新排序,请使用order_branch_free选项:
// reordering tasks within the whole gantt gantt.config.order_branch = true; gantt.config.order_branch_free = true; gantt.init("gantt_here");
2、拒绝下降到特定位置
要拒绝将任务放到特定位置,请使用onBeforeTaskMove或onBeforeRowDragEnd事件:
//prevent moving to another sub-branch: gantt.attachEvent("onBeforeTaskMove", function(id