Need to Execute Code After All Gantt Event Handlers Have Finished

Hi,

I’m looking for a way to execute my code only once after all Gantt event handlers have finished running.

For example, when I drag a project in the Gantt chart, events like onBeforeTaskUpdate and onAfterTaskUpdate are triggered multiple times, depending on how many tasks were affected by the change.

Dragging a project is just one example, but in my Gantt solution, a single user action often changes multiple tasks.

What I need is to run my code once, but only after all the events related to that action have finished. I couldn’t find any API method that directly provides this functionality.

I’ve seen that there’s an onAfterBatchUpdate event, but this doesn’t fit my case because I’m not always performing batch updates.

Is there a way to detect when Gantt has finished all its event handlers after a change?

Thanks for your help!

Hello Kam,
Unfortunately, Gantt doesn’t have such an event. There are many ways to configure Gantt, so, there is no universal event handler that fires after all other events are triggered.
For example, if you drag a project task, you can save the ID of the dragged task in the onBeforeTaskDrag event handler, then check it in the onAfterTaskDrag event handler.
Here is an example of how it can be implemented:
https://snippet.dhtmlx.com/4wcza0l8

However, if you enable auto-scheduling, you need to rely on the onAfterAutoSchedule event:
https://docs.dhtmlx.com/gantt/api__gantt_onafterautoschedule_event.html

Here is the snippet:
https://snippet.dhtmlx.com/vbtuyxsz