gantt.attachEvent("onBeforeTaskDelete", function (id, item) {
//any custom logic here
var sourceLinks = item.$source;
var targetLinks = item.$target;
for (let i = 0; i < sourceLinks.length; i++) {
gantt.deleteLink(sourceLinks[i]);
}
for (let j = 0; j < targetLinks.length; j++) {
gantt.deleteLink(targetLinks[j]);
}
return true;
});
in this code deltes the first link and does not wait for response. Does not delete second related link and again deletes third link and so on. Is there any way to await the deleteion until response?
Hello Komek,
Usually, when you delete a task, Gantt deletes all its links. I tried to reproduce it, and it works correctly.
Could you clarify if you want to delete links before deleting a task and why do you need that?
Hello Ramil.
Tanks for your reply. I want to delete task. and when I delete task I want to delete all related links to the task.
I used below codes for deleting related links to the task.
gantt.attachEvent("onBeforeTaskDelete", function (id, item) {
//any custom logic here
var sourceLinks = item.$source;
var targetLinks = item.$target;
for (let i = 0; i < sourceLinks.length; i++) {
gantt.deleteLink(sourceLinks[i]);
}
for (let j = 0; j < targetLinks.length; j++) {
gantt.deleteLink(targetLinks[j]);
}
return true;
});
gantt.attachEvent('onAfterLinkDelete', (id) => {
this.linkService.remove(id);
});
in this situation when I delete task “New task 5”, I want to delete all links from db.
the above code deletes the links from “New task 1” to “New task 5” and from “New task 3” to “New task 5”,
does not delete link between “New task 2” to “New task 5”.
So is there any way await the procedure until first delete operation completed or anything like this?
Hello Ramil.
Thanks for your help.
I copied dhtmlxgantt.js and dhtmlxgantt.js.map files from demo you give link above, to my project’s files.
I worked without any problem. Thanks again.
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan