а

Drag-and-Drop - tasks validations


#1

Hello,
I need help to do a validation on drag-and-drop. The task not allowed to move to the root, she always need the project before (at a root) or another task with a project before. Its possible to have n projects but the projects need to be in root of gantt(validation I already did).
I try to use “OnBeforeTaskMove” and task.$level but is not working.
Anyone helps me?
Thank you.


#2

Hello,
You can use the onBeforeRowDragEnd and check the task parent there:
https://docs.dhtmlx.com/gantt/api__gantt_onbeforerowdragend_event.html
When the parent is 0, you return false.
Here is an example of how it might be implemented:
http://snippet.dhtmlx.com/0cc36f4b7
You can also check the following sample where you can cancel reordering tasks:
https://snippet.dhtmlx.com/ce5723d5d