DevExtreme v24.2 is now available.

Explore our newest features/capabilities and share your thoughts with us.

Your search did not match any results.

React Scheduler - Disabled Date/Time Ranges

This demo shows how to disable specific days, dates, and times when a user cannot schedule an appointment. In the demo, appointments are disabled for weekends, certain individual dates (e.g., May 25th), and the time period from 12:00pm to 1:00pm.

To give you the ability to edit code on the fly, the demo uses SystemJS. For this reason, launching the demo takes some time. We strongly recommend that you do not use this approach in real projects.
Backend API

To implement this functionality in your application, follow the steps below:

  1. Implement custom date/time validation functions
    These functions should check whether a date or time is available. This demo includes the date/time validation functions listed below. In your application, they can be different.

    • isValidAppointment
      Prepares data and begins validation.
    • isValidAppointmentInterval
      Validates a date/time interval.
    • isValidAppointmentDate
      Calls the isHoliday, isWeekend, and isDinner functions.
    • isHoliday / isWeekend / isDinner
      Check whether a date/time interval is a holiday, a weekend, or dinner time.
  2. Validate appointments before they are created or updated
    Before an appointment is created or updated, the Scheduler executes the onAppointmentAdding and onAppointmentUpdating functions. Use them to start validation. If a date or time is invalid, cancel the creation or update. Implement the same logic in the onAppointmentFormOpening function so that users cannot open the appointment details form for a disabled date or time.

  3. Customize the appointment details form
    The appointment details form includes two calendars that allow users to select an appointment's start and end date/time. You should also disable dates in these calendars. Review the applyDisableDatesToDateEditors function to see how this is done. Call this function from onAppointmentFormOpening.

  4. Customize the timetable appearance
    Use templates to customize the appearance of data cells (dataCellTemplate), time cells (timeCellTemplate), and date cells (dateCellTemplate). In this demo, date cell customization is visible only in the Month view. To switch to this view, use the view switcher in the Scheduler's upper right corner.