All docs
V24.2
24.2
24.1
23.2
23.1
22.2
22.1
21.2
21.1
20.2
20.1
19.2
The page you are viewing does not exist in version 19.2.
19.1
The page you are viewing does not exist in version 19.1.
18.2
The page you are viewing does not exist in version 18.2.
18.1
The page you are viewing does not exist in version 18.1.
17.2
The page you are viewing does not exist in version 17.2.

JavaScript/jQuery Scheduler - 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 where users can choose 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 property.

jQuery
$(function() {
    $("#schedulerContainer").dxScheduler({ 
        // ...
        recurrenceEditMode: 'occurrence' // or 'series' | 'dialog'
    });
});
Angular
HTML
TypeScript
<dx-scheduler ...
    recurrenceEditMode="occurrence"> <!-- or 'series' | 'dialog' -->
</dx-scheduler>
import { DxSchedulerModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxSchedulerModule
    ],
    // ...
})
Vue
App.vue
<template>
    <div>
        <DxScheduler
            recurrence-edit-mode="occurrence" /> <!-- or 'series' | 'dialog' -->
    </div>
</template>

<script>
import 'devextreme/dist/css/dx.light.css';

import DxScheduler from 'devextreme-vue/scheduler';

export default {
    components: {
        DxScheduler
    }
}
</script>
React
App.js
import React from 'react';

import 'devextreme/dist/css/dx.light.css';

import Scheduler from 'devextreme-react/scheduler';

class App extends React.Component {
    render() {
        return (
            <Scheduler recurrenceEditMode="occurrence" /> {/* or 'series' | 'dialog' */}
        );
    }
}
export default App;

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

jQuery
JavaScript
$(function() {
    $("#schedulerContainer").dxScheduler({ 
        // ...
        editing: { allowDeleting: false }
    });
});
Angular
HTML
TypeScript
<dx-scheduler ... >
    <dxo-editing [allowDeleting]="false"></dxo-editing>
</dx-scheduler>
import { DxSchedulerModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxSchedulerModule
    ],
    // ...
})
Vue
App.vue
<template>
    <DxScheduler ... >
        <DxEditing :allow-deleting="true" />
    </DxScheduler>
</template>

<script>
import 'devextreme/dist/css/dx.light.css';

import DxScheduler, { DxEditing } from 'devextreme-vue/scheduler';

export default {
    components: {
        DxScheduler,
        DxEditing
    },
    data() {
        return {
            // ...
        }
    }
}
</script>
React
App.js
import React from 'react';

import 'devextreme/dist/css/dx.light.css';

import Scheduler, { Editing } from 'devextreme-react/scheduler';

class App extends React.Component {
    render() {
        return (
            <Scheduler ... >
                <Editing allowDeleting={true} />
            </Scheduler>
        );
    }
}
export default App;

API

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

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

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

    $("#deleteButton").dxButton({
        text: "Delete",
        onClick: function () {
            scheduler.deleteAppointment(appointments[0]);
        }
    });
});
Angular
HTML
TypeScript
<dx-scheduler
    [(dataSource)]="appointments"
    [currentDate]="currentDate">
</dx-scheduler>

<dx-button
    text="Delete"
    (onClick)="deleteAppointment()">
</dx-button>
import { ..., ViewChild } from "@angular/core";
import { DxButtonModule, DxSchedulerModule, DxSchedulerComponent } from "devextreme-angular";
// ...
export class AppComponent  {
    @ViewChild(DxSchedulerComponent, { static: false }) scheduler: DxSchedulerComponent;
    // Prior to Angular 8
    // @ViewChild(DxSchedulerComponent) scheduler: DxSchedulerComponent;
    appointments = [{
        text: "Website Re-Design Plan",
        startDate: new Date("2016-04-25T09:00:00.000Z"),
        endDate: new Date("2016-04-25T09:30:00.000Z")
    }, 
    // ...
    ];
    currentDate = new Date(2016, 4, 25);

    deleteAppointment() {
        this.scheduler.instance.deleteAppointment(this.appointments[0]);
    }
}
@NgModule({
    imports: [
        // ...
        DxSchedulerModule,
        DxButtonModule
    ],
    // ...
})
Vue
App.vue
<template>
    <div>
        <DxScheduler
            :data-source="dataSource"
            :current-date="currentDate"
            :ref="schedulerRefKey"
        />
        <DxButton
            text="Delete"
            @click="deleteAppontment"
        />
    </div>
</template>

<script>
import 'devextreme/dist/css/dx.light.css';

import DxScheduler from 'devextreme-vue/scheduler';
import DxButton from 'devextreme-vue/button';

const schedulerRefKey = "my-scheduler";

export default {
    components: {
        DxScheduler,
        DxButton
    },
    data() {
        return {
            dataSource: [{
                text: "Planning",
                startDate: new Date("2016-04-25T09:00:00.000Z"),
                endDate: new Date("2016-04-25T09:30:00.000Z")
            }, 
            // ...
            ],
            currentDate: new Date(2016, 4, 25),
            schedulerRefKey
        },
    },
    methods: {
        deleteAppontment() {
            this.scheduler.deleteAppointment(this.appointments[0]);
        }
    },
    computed: {
        scheduler: function() {
            return this.$refs[schedulerRefKey].instance;
        }
    }
}
</script>
React
App.js
import React from 'react';

import 'devextreme/dist/css/dx.light.css';

import Scheduler from 'devextreme-react/scheduler';
import Button from 'devextreme-react/button';

const appointments = [{
    text: "Website Re-Design Plan",
    startDate: new Date("2016-04-25T09:00:00.000Z"),
    endDate: new Date("2016-04-25T09:30:00.000Z")
}, 
// ...
];

class App extends React.Component {
    constructor(props) {
        super(props);
        this.schedulerRef = React.createRef();
        this.deleteAppointment = this.deleteAppointment.bind(this);
    }

    get scheduler() {
        return this.schedulerRef.current.instance();
    }

    deleteAppointment() {
        this.scheduler.deleteAppointment(this.appointments[0]);
    }

    render() {
        return (
            <React.Fragment>
                <Scheduler
                    dataSource={appointments}
                    defaultCurrentDate={new Date(2016, 4, 25)}
                />
                <Button
                    text="Delete"
                    onClick={this.deleteAppointment}
                />
            </React.Fragment>
        );
    }
}
export default App;

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 UI component, assign it to the corresponding onEventName property when you configure the UI component.

jQuery
JavaScript
$(function () {
    $("#schedulerContainer").dxScheduler({ // ...
        onAppointmentDeleting: function (e) {
            // Handler of the "appointmentDeleting" event
        },
        onAppointmentDeleted: function (e) {
            // Handler of the "appointmentDeleted" event
        }
    });
});
Angular
HTML
TypeScript
<dx-scheduler ...
    (onAppointmentDeleting)="onAppointmentDeleting($event)"
    (onAppointmentDeleted)="onAppointmentDeleted($event)">
</dx-scheduler>
import { DxSchedulerModule } from "devextreme-angular";
// ...
export class AppComponent {
    onAppointmentDeleting (e) {
        // Handler of the "appointmentDeleting" event
    }

    onAppointmentDeleted (e) {
        // Handler of the "appointmentDeleted" event
    }
}
@NgModule({
    imports: [
        // ...
        DxSchedulerModule
    ],
    // ...
})
Vue
App.vue
<template>
    <DxScheduler ...
        @appointment-deleting="onAppointmentDeleting"
        @appointment-deleted="onAppointmentDeleted"
    />
</template>

<script>
import 'devextreme/dist/css/dx.light.css';

import DxScheduler from 'devextreme-vue/scheduler';

export default {
    components: {
        DxScheduler
    },
    data() {
        return {
            // ...
        },
    },
    methods: {
        onAppointmentDeleting: (e) => {
            // Handler of the "appointmentDeleting" event
        },
        onAppointmentDeleted: (e) => {
            // Handler of the "appointmentDeleted" event
        }
    }
}
</script>
React
App.js
import React from 'react';

import 'devextreme/dist/css/dx.light.css';

import Scheduler from 'devextreme-react/scheduler';

const onAppointmentDeleting = (e) => {
    // Handler of the "appointmentDeleting" event
}
const onAppointmentDeleted = (e) => {
    // Handler of the "appointmentDeleted" event
}

class App extends React.Component {
    render() {
        return (
            <Scheduler ...
                onAppointmentDeleting={onAppointmentDeleting}
                onAppointmentDeleted={onAppointmentDeleted}
            />
        );
    }
}
export default App;
jQuery

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