Delete event programmatically with confirm dialog

Hello,

I'm trying to delete event programmatically this.scheduleObj.deleteEvent(event.id); and everything works fine but I don't get the confirmation dialog doing it this way. if I delete event using key "Delete" the confirmation dialog is shown.

Do I have to add anything so that dialog gets shown? or is this a problem on your end?

Regards.
Marko

4 Replies

VM Vengatesh Maniraj Syncfusion Team February 12, 2020 11:54 AM UTC

Hi Marko, 

Greetings from Syncfusion Support. 

When we delete an event by programmatically by making use of deleteEvent method, we could not display the delete alert. But if we want to show the delete alert we need to set the event object to the Schedule’s activeEventData and call the openDeleteAlert method for normal event and for recurrence events call the deleteClick method like below, 

For Normal Event delete: 
  let events = this.scheduleObj.getCurrentViewEvents(); 
  //set the event object which one you want delete. 
 (this.scheduleObj.activeEventData as any).event= events[0]; 
   //to delete the normal event 
  this.scheduleObj.quickPopup.openDeleteAlert(); 

For Recurrence event delete: 
 let events = this.scheduleObj.getCurrentViewEvents(); 
 //set the event object which one you want delete. 
 (this.scheduleObj.activeEventData as any).event= events[0]; 
 this.scheduleObj.quickPopup.quickPopupHide(); 
 this.scheduleObj.quickPopup.deleteClick(); 
 


Kindly try the above sample and revert us for further assistance. 

Regards, 
Vengatesh 



MB Marko Bezjak February 12, 2020 12:48 PM UTC

Thank you. Your solution works :)

Regards.
Marko


MB Marko Bezjak February 12, 2020 04:31 PM UTC

I thanked you a bit to early. The deleting works fine until you add new event into schedule. When you add new event and press the delete button.. the dialog will appear.. but after pressing ok it wont actually delete any events.

Regards.
Marko


VM Vengatesh Maniraj Syncfusion Team February 13, 2020 10:27 AM UTC

Hi Marko, 
 
Thanks for the update. 
 
We could reproduce the reported problem at our end and we have resolved it by setting null to currentAction of Schedule like below, 
 
btnClick(){ 
      //To explain we get the data from this method. 
      this.scheduleObj.currentAction = null; 
      let events = this.scheduleObj.getCurrentViewEvents(); 
      //set the event object which one you want delete. 
      (this.scheduleObj.activeEventData as any).event= events[0]; 
      //to delete the normal event 
      this.scheduleObj.quickPopup.openDeleteAlert(); 
 
      //if you want delete recurrence events use the below two line instead line number 21. 
      // this.scheduleObj.quickPopup.quickPopupHide(); 
      // this.scheduleObj.quickPopup.deleteClick(); 
    } 


Kindly try the above sample and revert us for further assistance. 

Regards, 
Vengatesh 


Loader.
Up arrow icon