Refresh custom columns


#1

We have created a custom task types (“Project” and “Task”) to separate the grouping of tasks from the task type “Resources assignment”. We are capturing duration and assigned hours, for the “ResourceTask” type, but not for “Projects” and “Tasks”.

In the grid, duration and assigned hours are summarized for “Project” and “Task”, see code snippet below. But we struggle to get the calculation updating when editing tasks/drag without complete refresh. Complete refresh takes time and ruins the current GANTT focus.

Any ideas how to keep the grid updated without full refresh?

{label: “Ass.”, name: “assignedHours”, width: 40, align: “center”, resize: false, template: function(task) {
if(task.hours != null) return (task.duration * parseFloat(task.hours));
if (task.type != gantt.config.types.resourceTask) {
let sumAssignedHours = 0;
gantt.eachTask(function (task) {
if (task.type == gantt.config.types.resourceTask) {
sumAssignedHours += (task.duration * task.hours);
};
}, task.id);
return sumAssignedHours


#2

Hello,
If you modify the task properties, you need to repaint the task to see the changes. It is not necessary to use the gantt.render() or gantt.refreshData() to see the changes. You only need to call the gantt.refreshTask(id) method after recalculating the assigned hours.

Here is an example of how it works:
http://snippet.dhtmlx.com/5/2cd60b805