翻譯|使用教程|編輯:秦林|2022-10-14 13:45:22.487|閱讀 218 次
概述:這篇文章給大家講解dhtmlxGantt如何實(shí)現(xiàn)重新排序。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
這篇文章給大家講解dhtmlxGantt如何實(shí)現(xiàn)重新排序。
dhtmlxGantt 提供了 2 種方式在網(wǎng)格中重新排序任務(wù):
方法是可選的。默認(rèn)情況下,這兩種模式都被禁用。
要啟用拖放重新排序,請(qǐng)使用order_branch選項(xiàng):
gantt.config.order_branch = true; gantt.init("gantt_here");
order_branch選項(xiàng)允許在同一樹(shù)級(jí)別內(nèi)拖動(dòng)任務(wù)。
還可以啟用可以在整個(gè)甘特圖中重新排序任務(wù)的模式。這意味著一個(gè)任務(wù)可以替換任何樹(shù)級(jí)別的另一個(gè)任務(wù)。要使用這種類型的任務(wù)重新排序,請(qǐng)使用order_branch_free選項(xiàng):
// reordering tasks within the whole gantt gantt.config.order_branch = true; gantt.config.order_branch_free = true; gantt.init("gantt_here");
要拒絕將任務(wù)放到特定位置,請(qǐng)使用onBeforeTaskMove或onBeforeRowDragEnd事件:
//prevent moving to another sub-branch: gantt.attachEvent("onBeforeTaskMove", function(id, parent, tindex){ var task = gantt.getTask(id); if(task.parent != parent) return false; return true; }); //or gantt.attachEvent("onBeforeRowDragEnd", function(id, parent, tindex){ var task = gantt.getTask(id); if(task.parent != parent) return false; return true; });
如果您的甘特圖包含大量任務(wù),則分支重新排序的默認(rèn)模式可能會(huì)降低性能。為了加快速度,您可以使用“標(biāo)記”模式。
gantt.config.order_branch = "marker";
在此模式下,僅重新排序任務(wù)的名稱(按住鼠標(biāo)左鍵),并且僅當(dāng)將任務(wù)放在目標(biāo)位置(釋放鍵)時(shí)才重新渲染甘特圖。與默認(rèn)模式不同,任務(wù)位置的更改不涉及觸發(fā) onBeforeTaskMove/onAfterTaskMove 事件。
要防止將任務(wù)放在特定位置,請(qǐng)改用onBeforeRowDragMove事件(僅在“標(biāo)記”模式下有效)。
要在拖動(dòng)過(guò)程中突出顯示可用的目標(biāo)位置(例如,不能將根節(jié)點(diǎn)拖動(dòng)到另一個(gè)根節(jié)點(diǎn)下,并且您希望直觀地告知用戶這一點(diǎn)),請(qǐng)使用onRowDragStart和onRowDragEnd事件:
gantt.config.order_branch = true;// order tasks only inside a branch gantt.init("gantt_here"); gantt.parse(demo_tasks); var drag_id = null; gantt.attachEvent("onRowDragStart", function(id, target, e) { drag_id = id; return true; }); gantt.attachEvent("onRowDragEnd", function(id, target) { drag_id = null; gantt.render(); }); gantt.templates.grid_row_class = function(start, end, task){ if(drag_id && task.id != drag_id){ if(task.$level != gantt.getTask(drag_id).$level) return "cant-drop"; } return ""; };
dhtmlxGantt是用于跨瀏覽器和跨平臺(tái)應(yīng)用程序的功能齊全的Gantt圖表,可滿足項(xiàng)目管理控件應(yīng)用程序的所有需求,是最完善的甘特圖圖表庫(kù)。了解更多DhtmlxGantt相關(guān)內(nèi)容和資訊,歡迎在線咨詢或者私信我獲取正版試用版及報(bào)價(jià)。
甘特圖控件交流群:764148812 歡迎進(jìn)群交流討論
更多正版甘特圖軟件下載、購(gòu)買、授權(quán)咨詢,請(qǐng)點(diǎn)這里!
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@ke049m.cn