Task overlapping

Hello everybody,

Is there any way to prevent the two tasks from overlapping when using drag and drop?

I don’t want to use “gantt.config.auto_scheduling” because when using “auto_scheduling” it will affect the position of the “linked” tasks pointing to

Hi @longhai,
Unfortunately, there is no built-in functionality for this, but it could be implemented in a custom solution. The logic of this solution is to find siblings of the dragged task and compare the start/end dates of the dragged task with the start/end dates of his siblings. After that you will be able to apply/decline drag inside onBeforeTaskChanged event, here is the snippet:
http://snippet.dhtmlx.com/d83444547
As I understand, you are using the custom vertical ‘dnd’ solution, is it?
It is so, here is a modified vertical ‘dnd’ solution, with preventing of vertical/horizontal overlap:
http://snippet.dhtmlx.com/87edc8827
The main logic of this one is to find new parents of the task before when drag, add styles when it overlaps with new parents and apply/decline the task drag inside onBeforeTaskChanged.
The logic of overlap detecting is placed inside isOverlapDetected() function.

1 Like

Hi @Siarhei,
Thank you for that snippet,
It work for me haha ^^.
Have a nice day to you.

1 Like