这篇文章给大家讲解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, parent, tindex){
var task = gantt.getTask(id);
if(task.parent != parent)

本文介绍dhtmlxGantt如何启用拖放和排序功能进行任务重新排序,包括order_branch和order_branch_free选项的使用,以及在大型数据集下的性能优化策略。通过onBeforeTaskMove等事件控制任务放置位置,实现甘特图的高效管理。
最低0.47元/天 解锁文章
1336

被折叠的 条评论
为什么被折叠?



