Move dependency when task is moved

I’ve done a lot of searching and trying different things to get this to work but I haven’t been able to get it. I want it so that when a task is moved, all of the dependencies below it are moved equally. From what I’ve read this has been requested several times.

A lot of the responses say to use the onTaskDrag event but that event is called for every pixel the task is moved. It uses too much memory doing this. However from what I can tell this is the only way to get the original start/duration.

I need to get the original and end start date so that I can calculate how many days the task was moved. Then I can move the sub tasks the same distance. This seems like the only way accomplish this.

Is there a plan to put this into dhtmlxgantt? One of the main purposes of having links is so that you can move a task and it moves the linked tasks automatically.
If not, what would be the best way to accomplish this? Maybe with more examples? It seems like a lot of people want this so more information would definitely help.

Hello,
there are several approaches you could try

  1. Firstly, there is auto scheduling extension which should do pretty much what you’ve described
    docs.dhtmlx.com/gantt/desktop__a … uling.html

  2. Or, you can move all dependencies on onTaskDrag event. You’ll need to manually iterate dependent task, here is how can you retreive the links docs.dhtmlx.com/gantt/desktop__l … ertaintask
    and from the links you can get the dependent tasks.
    If you don’t have too much of linked tasks this approach can work reasonably fast, also some improvements can be done in order to limit performance draw.
    Here is a demo:
    docs.dhtmlx.com/gantt/snippet/4dbc2bb5

  3. Or, you can move all dependent tasks after drag and drop is finished. The code will be very similar to (2), the difference is that you’ll probably need to use onBeforeTaskChanged event to get a diff value.
    Here is a demo
    docs.dhtmlx.com/gantt/snippet/34c55b8d

docs.dhtmlx.com/gantt/api__gantt … event.html

1 Like

Thanks you very much!

How can I do not calculate the week-end?

Hello Sara,
If you hide the weekends, you can use dateFromPos commands to get the dates, here is an example with the different implementation of that functionality:
http://snippet.dhtmlx.com/b730710cf

If you need something else, please give me more details on what you need.

1 Like

It’s perfect! Thank you very much!