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 property.
- <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>
To prevent a user from deleting an appointment, set the editing.allowDeleting property to false.
- <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>
API
To delete an appointment, call the deleteAppointment(appointment) method. This method deletes an appointment defined by the parameter from the data source.
- <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>
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.
- <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>
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. This approach is more typical of jQuery.
- 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
If you have technical questions, please create a support ticket in the DevExpress Support Center.