In the Scheduler, there is an event called "beforeeventdelete" that could be listened, in order to prevent or control an event to be deleted.
In the Gantt there is no such of event in the lifecycle hook? (Look at the screenshot)
There is only "rowremove" event, which is too late since the task (row) is removed and we need to catch that before the row is permanently deleted (removed).
How can we listen up a task that is being deleted ? as it exists in the scheduler
And you refer to a row while the Gantt is dealing with Task (or event)! wouldn't it be better to name that (removeTask) instead of row, since that could be a bit confusing with the Grid that mainly deals with row?
Re: How to fire "before....delete" event in Gantt ?
Re: How to fire "before....delete" event in Gantt ?
Posted: Thu May 30, 2019 12:51 pm
by SIM-LTD
Hi Mats
'Nops' this does not work at all.
We did try that out before requiring some tiny help from you.
Indeed, as you can see our code below :
// Listener on the Gantt Task
gantt.on({
aftertaskdrop : this.myGanttOnTaskChange,
taskresizeend : this.myGanttOnTaskChange,
//beforeRemove : this.myGanttOnTaskChange // THIS DOES NOT WORK AT ALL !!! Only for the Store...
rowremove : this.myGanttOnTaskChange // THIS IS OK BUT IS TOO LATE
})
But "rowremove" is fired after the event being deleted (removed) then, is too late to undertake any preventing/controlling action.
We tired with :
// Listener on the Gantt Task Store
gantt.taskStore.on({
change : this.myGanttTaskStoreChange,
beforeRemove : this.myGanttTaskStoreChange
})
But we would like to pop up a confirmation message for deleting and either stop the propagation when NO or, leave the process running is YES.
But adding a listener onto the taskStore, seems to be too late to step in the process so as to stop it.
Thus, having spent time struggling with that, we would like to know how did you manage for preventing a Gantt Task to be deleted?
Re: How to fire "before....delete" event in Gantt ?
Default context menu handler calls `taskRecord.remove();` which doesn't fire `beforeRemove` event.
But you can provide your own handler or even a new item to the context menu:
features : {
taskContextMenu : {
items : {
deleteTask : {
onItem : ({ taskRecord }) => {
// taskStore.remove triggers beforeRemove event
// also here you can show a confirmation dialog
// and then call removing method
gantt.taskStore.remove(taskRecord);
}
}
}
},
Hope this will help you to deal with the issue.
Best wishes,
Pavel
Re: How to fire "before....delete" event in Gantt ?
Posted: Fri May 31, 2019 8:49 am
by SIM-LTD
Thank you Pavel for your response which is as usual perfect.
Cheers
Re: How to fire "before....delete" event in Gantt ?
Posted: Sun Aug 04, 2019 7:24 pm
by SIM-LTD
Hi
This issue was supposed to be fixed according to the previous post (Fixed-#8571: Node remove%28%29 doesn't fire "beforeremove" on the task store)
But we are very sorry to tell you this is not the case.
As a matter of fact, in our app this event "beforeremove" is not fired at all, so we have double-checked online
( https://www.bryntum.com/examples/gantt/basic/ )
Please add this line code :
const gantt = new Gantt({
........
gantt.taskStore.on({
beforeremove({ records }) {
console.log('Task before remove....', records)
}
});
And nothing is fired?
No matter if we use DEL key from keyboard OR remove from the context menu or Delete button in the task editor.
The event "beforeremove" is at all fired...
This is becoming a real issue for us; because we need to get this so as to send a popup confirmation.
Re: How to fire "before....delete" event in Gantt ?
Posted: Mon Aug 05, 2019 6:50 pm
by pmiklashevich
taskStore is a tree store, so using 'beforeRemove' is conceptually wrong. Please see beforeRemoveChild event:
Re: How to fire "before....delete" event in Gantt ?
Posted: Mon Aug 05, 2019 7:09 pm
by SIM-LTD
Hi
Ok, thank you let us know.
Could you Please be a bit "NICE" in your answer.
Because our request concern the GANTT and you pointed out a method from the GRID documentation.
you quoted...
Please see beforeRemoveChild event:
;
Then, if you to the Gantt documentation (see our screenshot), there is nothing regarding 'beforeRemoveChild" in the Gantt Document.
There is only "beforeRemove" and moreover, in the quick search, the word "beforeremove" does not popup...
Thank you anyway; we'll try "beforeRemoveChild to see if this works.
And do not forget to update your Gantt Doc... Cheers
Re: How to fire "before....delete" event in Gantt ?
Posted: Mon Aug 05, 2019 8:31 pm
by pmiklashevich
Gantt docs extend Grid and Scheduler. This doc part is new. It's available online in Grid and Scheduler because Grid and Scheduler were released after this change. Gantt hasn't been released yet, which means I have nothing to point to online. Before give a reply to you, I check online docs, codebase and try manually in our online examples in console.
Re: How to fire "before....delete" event in Gantt ?
Posted: Mon Aug 05, 2019 8:54 pm
by SIM-LTD
Hi Pavel
We did not really understand your last answer.... anyway
We just tested your code; And we are so sorry to announce you that this code "beforeRemoveChild" DO NOT WORK AT ALL
Then no matter if the taskStore is a 'Tree' (we call this a hierarchy data structure) or Flat record, no event "beforeRemove..." is fired.
By the way, we have also another post with "BeforeAdd" (viewtopic.php?f=52&t=11890 Ticket #8989) for which you have opened up a ticket because it is not fired as well...
At last, it seems that in the Gantt & in the Scheduler all events "Before...." are not fired.
Indeed in the scheduler, we have also another issue (viewtopic.php?f=44&t=11668 Ticket #8910) for which "beforeeventdelete" is not fired...
We really hope that the upcoming release (Gantt & Scheduler) will have all these issues fixed. Because this is becoming a critical point in our process implementation