How to update parent progress automatically?

I am using gantt chart as in the example dhtmlx.com/docs/products/dhtmlxG … basic.html
I need to update the progress percentage of parent with its child values,Is possible to do like that?

When a sub task’s progress is updated,Then the progress of its parent is automatically updated based on the progress of child tasks.

Hi,
there is no built-in method, but you can catch the event when a task has been modified. Then you could retrieve a chain of parent tasks and recalculate their progress
docs.dhtmlx.com/gantt/api__gantt … event.html
docs.dhtmlx.com/gantt/api__gantt … event.html
docs.dhtmlx.com/gantt/api__gantt … event.html
docs.dhtmlx.com/gantt/api__gantt_gettask.html
docs.dhtmlx.com/gantt/api__gantt_updatetask.html

var parent = gantt.getTask(task.parent); parent.progress = some_value; gantt.updateTask(parent.id);

You can try this :

gantt.attachEvent("onAfterTaskUpdate", function(id,item){
		if (item.parent == 0) {
			return;
		}
		
		var parentTask = gantt.getTask(item.parent); //console.log(parent.id);return;
		
		var childs = gantt.getChildren(parentTask.id);
		var totProgress = 0;
		
		var tempTask;
		for (i = 0; i < childs.length; i++) { //console.log(childs[i]);
			tempTask = gantt.getTask(childs[i]);
			totProgress += parseFloat(tempTask.progress);
		}
		//console.log(totProgress);
		
		parentTask.progress = (totProgress / childs.length).toFixed(2);
		gantt.updateTask(parentTask.id);
	});

this code works only

in this hierarchy

parent task 10
sub task parent 40
sub task 42

but not ( see the attachment )

parent task 10
sub task 40
sub task 42
sub task 44


Hi,
please provide some kind of demo. The issue seems to be caused by something in the data you have in a chart.
You can try reproducing the error using this tool:
docs.dhtmlx.com/gantt/snippet/8b862977

it works perfectly using your snippet area, thanks let me examine again why this is happening