Scheduler prevent default action for 'remove' event

1 Answer 485 Views
Scheduler wrapper
Al
Top achievements
Rank 1
Iron
Iron
Iron
Al asked on 19 Jul 2021, 01:45 PM

I am using custom screens and UI to interact with the scheduler so I am overriding the default behviour eg. fFor the 'edit' event I call e.preventDefault() and then show my screen to do whatever is necessary.

 

I can't figure out how to do this for 'remove' though as it seems that the remove event only fires after the built-in "do you want to delete the event" prompt is shown and ok is clicked.

I don't want to show any built-in UI but want to show my own delete confirmation and then do the delete api call manually - how is this possible?

1 Answer, 1 is accepted

Sort by
0
Accepted
Petar
Telerik team
answered on 20 Jul 2021, 01:35 PM

Hi Al,

The targeted functionality of defining a custom popup when a task is removed from the Scheduler can be achieved using the approach discussed in this StackOverflow thread

Here is a StackBlitz example that implements the code from the above link. The key things in the sample are the following configurations:

:editable="{confirmation:false}"
@databound ="dataBound"

where dataBound is defined as it follows:

dataBound: function(e) {
    var scheduler = e.sender;
    $(".k-event").each(function () {
    var uid = $(this).data("uid");
    if (uid) {
        var event = scheduler.occurrenceByUid(uid);
        if (event) {
        $(this).find(".k-event-delete").click(function (clc) {
            // TODO: replace with nicer modal
            if (confirm('Do you want to delete ' + event.title + ' ?'))
            {
            scheduler.removeEvent(uid);
            }
            clc.preventDefault();
            clc.stopPropagation();
        });
        }
    }
    });
}

Check the linked sample implementation and let me know if you have questions about it. 

Looking forward to your reply.

Regards,
Petar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Al
Top achievements
Rank 1
Iron
Iron
Iron
commented on 21 Jul 2021, 09:10 AM

Ouch! Thanks I'll try this. I'll post a feature request to get a better way to handle this.
Petar
Telerik team
commented on 21 Jul 2021, 09:18 AM

Hi, Al.

Try the suggested approach and let me know if you need further assistance with the implementation.

Tags
Scheduler wrapper
Asked by
Al
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Petar
Telerik team
Share this question
or