Hello,
I am testing the gantt component a bit and i’ve bumped into a problem.
I have 4 tasks, as shown below:
I would like to take task 3 and move it under task 2, so task 2 to becomes the parent of task 3.
i did this as following:
[code]
var task = gantt.getTask(gantt.getSelectedId());
//we loop all tasks that are on the same level as the one we selected
var tasks = gantt.getChildren(task.parent);
var previousTaskId = undefined;
$.each(tasks, function (index, item) {
// we attach the previousId to the current element in the loop,
// the moment we reach the item that matches the selected item, we break out of the loop
// so we have the previous element in our variable
if (item != task.id) {
previousTaskId = item;
} else {
return false;
}
});
if (previousTaskId != undefined) {
// we change the parent of the selected task to match the above task
gantt.getTask(task.id).parent = previousTaskId;
gantt.updateTask(task.id);
gantt.render();
// then we change the type of the new parent task to 'project' and save that to
var previousTask = gantt.getTask(previousTaskId);
previousTask.type = "project";
gantt.updateTask(previousTaskId);
gantt.render();
}[/code]
This leaves me with the following result:
As you can see, the grid is ok. The task gets added to the new parent just fine, the problem is with the gantt itself. The parentTasks is now coloured green, as it should be, but i can still resize is, and it also doesnt take the length of its children. Can someone help me tackle this problem?