3 Answers, 1 is accepted
The Scheduler can be configured so that the user cannot delete events. In order to do this you can call Destroy with a "false" parameter as shown below. By default it is "true" and deletion of events is enabled.
This will have effect for all events. If you want to prevent the deletion only of specific events you can handle the Scheduler's Remove event, in which the event the user is trying to delete is accessible through the arguments, check whether the event fulfills a condition and cancel the deletion. In the following example we prevent the user from deleting an event with a specific title:
Unfortunately, scheduler_remove fires after the delete confirmation prompt, which looks really bad ("Do you want to delete this?" "yes?", "well you can't", "no, I don't know why we asked either"...)
As I have a set of events, only some of which are to be deletable, I would like only to have a delete confirmation prompt when delete is actually going to be possible for that specific event. (Or of course, conditional removal of the delete button itself).
Is this possible?
I agree that preventing the event is counter intuitive in the scenario you described. You could consider using a different approach - saving the information about whether an event can or cannot be removed in a field in the event itself. Then you can use template for the event render or not a custom class in the template based on that field value. In the databound event you can find all events that have that class (e.g. "non-removable") and hide their remove button. In addition to the databound event the edit event can be used to hide the Delete button from the Scheduler's Editor, which appears on double-clicking an event.
Here's a dojo example, which demonstrates this approach. The "Meeting" event has the nonRemovable field set to "non-removable". It is added as a class within its template. This allows its remove/Delete buttons to be hidden in mentioned event handlers.