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.
- 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.
- 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.
- 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.
- 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;
See Also
If you have technical questions, please create a support ticket in the DevExpress Support Center.