Delete Appointments

User Interaction

After a user clicks an appointment, the Scheduler displays a tooltip with two buttons. To delete an appointment, a user clicks the button with a bucket icon. Note that the appointment will be deleted from the data source.

If a user deletes a recurring appointment, the Scheduler displays a dialog that allows choosing between deleting the current appointment and deleting the entire series of recurring appointments. If you do not want this dialog to appear, choose the edit mode beforehand using the recurrenceEditMode option.

$(function() {
    $("#schedulerContainer").dxScheduler({
        // ...
        recurrenceEditMode: 'occurrence' // or 'series' | 'dialog'
    });
});

To prevent a user from deleting an appointment, set the editing | allowDeleting option to false.

JavaScript
$(function() {
    $("#schedulerContainer").dxScheduler({
        // ...
        editing: { allowDeleting: false }
    });
});

API

To delete an appointment, call the deleteAppointment(appointment) method. This method deletes an appointment defined by the parameter from the data source.

JavaScript
$(function() {
    var appointments = [{
        text: "Website Re-Design Plan",
        startDate: new Date(2016, 4, 25, 9, 00),
        endDate: new Date(2016, 4, 25, 9, 30)
    },
    // ...
    ];

    var scheduler = $("#schedulerContainer").dxScheduler({
        dataSource: appointments,
        currentDate: new Date(2016, 4, 25)
    }).dxScheduler("instance");

    $("#deleteButton").dxButton({
        text: "Delete",
        onClick: function () {
            scheduler.deleteAppointment(appointments[0]);
        }
    });
});

Events

To execute certain commands before or after an appointment was deleted, handle the appointmentDeleting or appointmentDeleted event. If the event handling function is not going to be changed during the lifetime of the widget, assign it to the corresponding onEventName option when you configure the widget.

JavaScript
$(function () {
    $("#schedulerContainer").dxScheduler({
        // ...
        onAppointmentDeleting: function (e) {
            // Handler of the "appointmentDeleting" event
        },
        onAppointmentDeleted: function (e) {
            // Handler of the "appointmentDeleted" event
        }
    });
});

If you are going to change event handlers at runtime, or if you need to attach several handlers to a single event, subscribe to the events using the on(eventName, eventHandler) method.

JavaScript
var deletedEventHandler1 = function (e) {
    // First handler of the "deleted" event
};

var deletedEventHandler2 = function (e) {
    // Second handler of the "deleted" event
};

$("#schedulerContainer").dxScheduler("instance")
    .on('appointmentDeleted', deletedEventHandler1)
    .on('appointmentDeleted', deletedEventHandler2);
See Also