Update inter dependent columns after column update


#1

Hi Support,
In our Gantt there is a status column. when we change the status column I want to update percent complete.
Is there a way to do that other than using attach event “onAfterTaskUpdate” ?

because we have several this type of inter column dependencies. doing all in one event will cause performance issue?

Thanks.
Rasagb


#2

Hello,

In our Gantt there is a status column. when we change the status column I want to update percent complete.
Is there a way to do that other than using attach event “onAfterTaskUpdate” ?

One of the options is to create an array with required data of the task’s status and progress. You can use the gantt.serverList() for this:
https://docs.dhtmlx.com/gantt/api__gantt_serverlist.html
and set it to options property in your editor.
You can use the Inline Editors Extension instead of onAfterTaskUpdate and save changes with onSave event:
https://docs.dhtmlx.com/gantt/desktop__inline_editors_ext.html
Once you’ve attached onSave handler, you can iterate through the array with the required progress values for the tasks:

    let value = task.status;
    let list = gantt.serverList("status");
    for (let i = 0; i < list.length; i++) {
        if (list[i].key == value) {
            task.progress = list[i].progress;
            gantt.refreshTask(state.id);
            return;
        }
    };

Please check the example of how it might be implemented:
https://snippet.dhtmlx.com/blx8jy6z

doing all in one event will cause performance issue?

Performance depends not only on the number of tasks but on the overall combination of settings applied to the Gantt.
If you update multiple tasks, you can repaint the changes only once with the help of batchUpdate method:
https://docs.dhtmlx.com/gantt/api__gantt_batchupdate.html