performance:onTaskDrag mode move parent and children task

Hello everybody,

currently i get performance problems on my Gantt Chart when i implement the following Code on my page

[code]gantt.attachEvent(“onTaskDrag”, function(id, mode, task, original, e){
var modes = gantt.config.drag_mode;
if(mode == modes.move){

	var diff = task.start_date - original.start_date; 
	var childrens = gantt.getChildren(id);
	for(var i = 0; i < childrens.length; i++)
	{
		var child = gantt.getTask(childrens[i]);
		child.start_date = new Date(+child.start_date + diff);
		child.end_date = new Date(+child.end_date + diff);
		gantt.refreshData(child.id);
	}

…[/code]

I know i can do that when i set the task type attribute at “project” but then is the parent task not moveable.

Before i paste this code in “onTaskDrag” Event i get a fast running program. Each task is moveable from date to date in milisecond response.
After i paste this code in “onTaskDrag” Event i get a slow running program. When i move the parent task i dont get a fast response on the gantt chart. If i wait two, three seconds after i moved the task, task jump then to the date where i moved before.

I have tried with eachTask function instead of for () loop or while loop with seperate counter…no improvement at performance.

I dont know why i get so a bad running system with this changes.

Can anyone help me?

Best regards
Axt

I have fixed it with a workaround.

After onAfterTaskDrag Event i calculate the new Date Position with values from the onBeforeTaskDrag Event.
A little bit complicate but it work.

Regards
Axt

Hello.

In your code you’re calling following code for child tasks:

gantt.refreshData(child.id);

This function refreshes whole gantt data and you shouldn’t call it for each task because it causes several re-renderings.
See article: docs.dhtmlx.com/gantt/api__gantt … hdata.html
You could call it once after tasks dates changing. Or you could call refreshTask to refresh specific tasks.
See article:
docs.dhtmlx.com/gantt/api__gantt … htask.html

Also notice that “gantt.getChildren(id);” returns only task children. You probably should use eachTask in case to go through whole sub-tree.