Vue Scheduler - Getting Started
The Scheduler component emulates the user interface of Calendar applications on Windows or Mac OS.
This tutorial adds DevExtreme Scheduler to a page, binds the component to data, and configures core Scheduler features.
Each section covers a single configuration step. The complete code is available in the following GitHub repository:
Create a Scheduler
Add DevExtreme to your Vue application and use the following code to create a Scheduler:
- <template>
- <DxScheduler id="scheduler>
- <!-- Configuration goes here -->
- </DxScheduler>
- </template>
- <script setup lang="ts">
- import 'devextreme/dist/css/dx.fluent.blue.light.css';
- import { DxScheduler } from 'devextreme-vue/scheduler';
- </script>
- <style>
- #scheduler {
- height: 600px;
- }
- </style>
Bind the Scheduler to Data
The DevExtreme Scheduler supports the following data source types:
To bind Scheduler to data, configure the dataSource property. Specify data field names following the structure of the SchedulerAppointment interface. To use custom field names, specify the following properties:
- <template>
- <DxScheduler
- :data-source="appointments"
- text-expr="title"
- all-day-expr="dayLong"
- recurrence-rule-expr="recurrence">
- </DxScheduler>
- </template>
- <script setup lang="ts">
- import { appointments } from './data.js';
- // ...
- </script>
- export const appointments = [
- {
- title: "Install New Database",
- startDate: new Date("2021-05-23T08:45:00.000Z"),
- endDate: new Date("2021-05-23T09:45:00.000Z")
- }, {
- title: "Create New Online Marketing Strategy",
- startDate: new Date("2021-05-24T09:00:00.000Z"),
- endDate: new Date("2021-05-24T11:00:00.000Z")
- }, {
- title: "Upgrade Personal Computers",
- startDate: new Date("2021-05-25T10:15:00.000Z"),
- endDate: new Date("2021-05-25T13:30:00.000Z")
- }, {
- title: "Customer Workshop",
- startDate: new Date("2021-05-26T08:00:00.000Z"),
- endDate: new Date("2021-05-26T10:00:00.000Z"),
- dayLong: true,
- recurrence: "FREQ=WEEKLY;BYDAY=TU,FR;COUNT=10"
- }, {
- title: "Prepare Development Plan",
- startDate: new Date("2021-05-27T08:00:00.000Z"),
- endDate: new Date("2021-05-27T10:30:00.000Z")
- }, {
- title: "Testing",
- startDate: new Date("2021-05-23T09:00:00.000Z"),
- endDate: new Date("2021-05-23T10:00:00.000Z"),
- recurrence: "FREQ=WEEKLY;INTERVAL=2;COUNT=2"
- }, {
- title: "Meeting of Instructors",
- startDate: new Date("2021-05-24T10:00:00.000Z"),
- endDate: new Date("2021-05-24T11:15:00.000Z"),
- recurrence: "FREQ=DAILY;BYDAY=WE;UNTIL=20211001"
- }, {
- title: "Recruiting students",
- startDate: new Date("2021-05-25T08:00:00.000Z"),
- endDate: new Date("2021-05-25T09:00:00.000Z"),
- recurrence: "FREQ=YEARLY",
- }, {
- title: "Monthly Planning",
- startDate: new Date("2021-05-26T09:30:00.000Z"),
- endDate: new Date("2021-05-26T10:45:00.000Z"),
- recurrence: "FREQ=MONTHLY;BYMONTHDAY=28;COUNT=1"
- }, {
- title: "Open Day",
- startDate: new Date("2021-05-27T09:30:00.000Z"),
- endDate: new Date("2021-05-27T19:00:00.000Z"),
- }
- ];
Set the Current Date
Use currentDate to specify the date displayed in the Scheduler:
- <template>
- <DxScheduler
- v-model:current-date="currentDate">
- </DxScheduler>
- </template>
- <script setup lang="ts">
- import { ref } from 'vue';
- // ...
- const currentDate = ref<Date>(new Date(2021, 4, 25));
- </script>
Configure Views
Read Tutorial: View Types Read Tutorial: Customize Individual Views
DevExtreme Scheduler ships with the following view types:
Specify the views[] array to define and customize Scheduler views. Specify each view's type value.
This example specifies the following views: Day, Week, and Month. Day and Week views use custom startDayHour and endDayHour values. The Month view uses the default configuration.
You can also specify the initial Scheduler view using currentView. This example initializes the component in the Week view:
- <template>
- <DxScheduler
- current-view="week">
- <DxView
- type="day"
- :start-day-hour="10"
- :end-day-hour="22"
- />
- <DxView
- type="week"
- :start-day-hour="10"
- :end-day-hour="22"
- />
- <DxView type="month" />
- </DxScheduler>
- </template>
- <script setup lang="ts">
- import { DxScheduler, DxView } from 'devextreme-vue/scheduler';
- </script>
Edit Appointments
Read Tutorial: Add Appointments Read Tutorial: Update Appointments Read Tutorial: Delete Appointments
Scheduler allows users to add, update, and delete appointments. All editing operations are enabled in the default configuration. To disable specific operations, configure the editing properties.
This tutorial disables allowDragging:
- <template>
- <DxScheduler>
- <DxEditing
- :allow-dragging="false"
- />
- </DxScheduler>
- </template>
- <script setup lang="ts">
- import { DxScheduler, DxEditing } from 'devextreme-vue/scheduler';
- </script>
When users add, update, or delete appointments, Scheduler calls the following event handlers:
You can use these handlers to extend Scheduler's functionality. The following example configures onAppointmentAdding and onAppointmentUpdating to prevent recurring appointments from sharing cells with other appointments:
Time Zone Support
Read Tutorial: Time Zone Support
Scheduler displays all appointments in the client time zone in the default configuration. To use a different time zone, specify the timeZone property. This option accepts IANA time zone identifiers. This tutorial sets the time zone to "Europe/Berlin".
Users can also edit the time zones of individual appointments when editing.allowTimeZoneEditing is enabled:
- <template>
- <DxScheduler
- time-zone="Europe/Berlin"
- >
- <DxEditing
- :allow-time-zone-editing="true"
- />
- <!-- ... -->
- </DxScheduler>
- </template>
Enable Adaptive Mode
The Scheduler interface can adapt to small screens. Set adaptivityEnabled to true to enable this capability. For more information, see the following demo:
- <template>
- <DxScheduler
- :adaptivity-enabled="true"
- />
- </template>
For further information on the Scheduler component, refer to the following resources: