Hi
When I click on the delete button of a task (Task #1)
Task #1 task delete
Task #1.1 task delete
Task #1.2 task delete…
How to not deleted task Task #1.1, Task #1.2?
Hi
When I click on the delete button of a task (Task #1)
Task #1 task delete
Task #1.1 task delete
Task #1.2 task delete…
How to not deleted task Task #1.1, Task #1.2?
Hi,
the tasks 1.1 and 1.2 are deleted because they are child elements of the task that is being deleted.
The only way to avoid this is to assign the affected items to another parent:
gantt.attachEvent("onBeforeTaskDelete", function(id,item){
var childs = gantt.getChildren(item.id);
for(var i=0; i < childs.length; i++){
gantt.getTask(childs[i]).parent = item.parent;//move one level up
gantt.updateTask(childs[i]);
}
return true;
});
It seems like the current version of gantt has bug related to changing of parent node. If you set parent=0 (and gantt.config.root_id == 0), the item will be deleted instead of being moved to the top level. It can be fixed with this patch, just add this code after adding dhtmlxgantt.js to the page:[code]gantt._move_branch = function(task, old_parent, new_parent){
task.parent = new_parent;
this._sync_parent(task);
this._replace_branch_child(old_parent, task.id);
if(this.isTaskExists(new_parent) || new_parent === this.config.root_id){
this._add_branch(task);
}else{
delete this._branches[task.id];
}
task.$level = this.calculateTaskLevel(task);
this._sync_order();
};[/code]
The fix will be included in the next versions of the component, so you’ll be able to remove this code when receive the newer version of the gantt