How to fire "before....delete" event in Gantt ?

Our state of the art Gantt chart
User avatar
SIM-LTD
Posts: 419
Joined: Thu Mar 28, 2019 4:12 pm

How to fire "before....delete" event in Gantt ?

Post by SIM-LTD » Thu May 30, 2019 10:52 am

Hi

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?
Attachments
Capture d’écran 2019-05-30 à 10.33.48.png
Capture d’écran 2019-05-30 à 10.33.48.png (98.67 KiB) Viewed 289 times

User avatar
mats
Core Developer
Core Developer
Posts: 14658
Joined: Sat Dec 19, 2009 11:41 pm
Location: Sweden
Contact:

Re: How to fire "before....delete" event in Gantt ?

Post by mats » Thu May 30, 2019 11:41 am

Tired of debugging javascript errors in web applications? Try our new error logging service RootCause, or read more on the Sencha blog

@bryntum
Facebook
API documentation

User avatar
SIM-LTD
Posts: 419
Joined: Thu Mar 28, 2019 4:12 pm

Re: How to fire "before....delete" event in Gantt ?

Post by SIM-LTD » Thu May 30, 2019 12:51 pm

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 :

Code: Select all

// 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 :

Code: Select all

// 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?

User avatar
pmiklashevich
Core Developer
Core Developer
Posts: 2301
Joined: Fri Apr 01, 2016 11:08 am

Re: How to fire "before....delete" event in Gantt ?

Post by pmiklashevich » Thu May 30, 2019 8:44 pm

Thanks for the report! Ticket here: https://app.assembla.com/spaces/bryntum/tickets/8571-node-remove()-doesn--39-t-fire-beforeremove-on-the-task-store/details

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:

Code: Select all

    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
Pavel Miklashevich - Core Developer

User avatar
SIM-LTD
Posts: 419
Joined: Thu Mar 28, 2019 4:12 pm

Re: How to fire "before....delete" event in Gantt ?

Post by SIM-LTD » Fri May 31, 2019 8:49 am

Thank you Pavel for your response which is as usual perfect.
Cheers :D

User avatar
SIM-LTD
Posts: 419
Joined: Thu Mar 28, 2019 4:12 pm

Re: How to fire "before....delete" event in Gantt ?

Post by SIM-LTD » Sun Aug 04, 2019 7:24 pm

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 :

Code: Select all

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... :evil:

This is becoming a real issue for us; because we need to get this so as to send a popup confirmation.

User avatar
pmiklashevich
Core Developer
Core Developer
Posts: 2301
Joined: Fri Apr 01, 2016 11:08 am

Re: How to fire "before....delete" event in Gantt ?

Post by pmiklashevich » Mon Aug 05, 2019 6:50 pm

taskStore is a tree store, so using 'beforeRemove' is conceptually wrong. Please see beforeRemoveChild event:

Code: Select all

gantt.taskStore.on({
    beforeRemoveChild({ childRecords }) {
        console.log('Task before remove....', childRecords)
    }     
});
Pavel Miklashevich - Core Developer

User avatar
SIM-LTD
Posts: 419
Joined: Thu Mar 28, 2019 4:12 pm

Re: How to fire "before....delete" event in Gantt ?

Post by SIM-LTD » Mon Aug 05, 2019 7:09 pm

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 :)
Attachments
Capture d’écran 2019-08-05 à 19.04.12.png
Capture d’écran 2019-08-05 à 19.04.12.png (160.53 KiB) Viewed 151 times

User avatar
pmiklashevich
Core Developer
Core Developer
Posts: 2301
Joined: Fri Apr 01, 2016 11:08 am

Re: How to fire "before....delete" event in Gantt ?

Post by pmiklashevich » Mon Aug 05, 2019 8:31 pm

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.
Pavel Miklashevich - Core Developer

User avatar
SIM-LTD
Posts: 419
Joined: Thu Mar 28, 2019 4:12 pm

Re: How to fire "before....delete" event in Gantt ?

Post by SIM-LTD » Mon Aug 05, 2019 8:54 pm

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

See our screenshot made in the online demo https://www.bryntum.com/examples/gantt/basic/

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
Attachments
Capture d’écran 2019-08-05 à 20.36.05.png
Capture d’écran 2019-08-05 à 20.36.05.png (174.59 KiB) Viewed 149 times
Capture d’écran 2019-08-05 à 20.36.09.png
Capture d’écran 2019-08-05 à 20.36.09.png (192.25 KiB) Viewed 149 times

Post Reply