Backend API
<dx-scheduler
timeZone="America/Los_Angeles"
[dataSource]="dataSource"
[views]="['day', 'week', 'workWeek', 'month']"
currentView="workWeek"
[currentDate]="currentDate"
[startDayHour]="9"
[endDayHour]="19"
[height]="600"
>
<dxi-scheduler-resource
fieldExpr="assigneeId"
label="Assignee"
[allowMultiple]="true"
[dataSource]="assignees"
icon="user"
>
</dxi-scheduler-resource>
<dxo-scheduler-toolbar>
<dxi-scheduler-toolbar-item
location="before"
name="today"
></dxi-scheduler-toolbar-item>
<dxi-scheduler-toolbar-item
location="before"
name="dateNavigator"
></dxi-scheduler-toolbar-item>
<dxi-scheduler-toolbar-item
location="before"
locateInMenu="auto"
widget="dxButton"
[options]="newEventButtonOptions"
>
</dxi-scheduler-toolbar-item>
<dxi-scheduler-toolbar-item location="before" locateInMenu="auto">
<div *dxTemplate>
<dx-select-box
placeholder="Select Employee"
[items]="assignees"
[showClearButton]="true"
displayExpr="text"
valueExpr="id"
[inputAttr]="{ 'aria-label': 'Select Employee' }"
[width]="200"
(onValueChanged)="onAssigneesChange($event)"
>
</dx-select-box>
</div>
</dxi-scheduler-toolbar-item>
<dxi-scheduler-toolbar-item
location="after"
locateInMenu="auto"
name="viewSwitcher"
></dxi-scheduler-toolbar-item>
</dxo-scheduler-toolbar>
</dx-scheduler>
import { bootstrapApplication } from '@angular/platform-browser';
import { Component, ViewChild, enableProdMode, provideZoneChangeDetection } from '@angular/core';
import { DxButtonModule, type DxButtonTypes } from 'devextreme-angular/ui/button';
import { DxSchedulerModule, DxSchedulerComponent } from 'devextreme-angular/ui/scheduler';
import { DxSelectBoxModule, type DxSelectBoxTypes } from 'devextreme-angular/ui/select-box';
import { Service } from './app.service';
const MS_IN_HOUR = 60 * 1000;
if (!/localhost/.test(document.location.host)) {
enableProdMode();
}
@Component({
styleUrls: [`app/app.component.css`],
selector: 'demo-app',
templateUrl: './app.component.html',
providers: [Service],
imports: [
DxButtonModule,
DxSchedulerModule,
DxSelectBoxModule,
],
})
export class AppComponent {
@ViewChild(DxSchedulerComponent, { static: true }) scheduler: DxSchedulerComponent;
dataSource = this.service.getAppointmentsDataSource();
assignees = this.service.getAssignees();
currentDate = this.service.getInitialCurrentDate();
newEventButtonOptions: DxButtonTypes.Properties = {
icon: 'plus',
text: 'New Appointment',
stylingMode: 'outlined',
type: 'normal',
onClick: () => { this.onAppointmentAdd(); },
};
constructor(private service: Service) {}
onAppointmentAdd() {
const selected = this.scheduler.instance.option('selectedCellData') ?? [];
if (selected.length) {
const firstSelected = selected[0];
const lastSelected = selected.at(-1);
this.scheduler.instance.showAppointmentPopup({
...firstSelected.groups,
allDay: firstSelected.allDay,
startDate: new Date(firstSelected.startDateUTC),
endDate: new Date(lastSelected.endDateUTC),
}, true);
return;
}
const currentDate = this.scheduler.instance.option('currentDate');
const cellDuration = this.scheduler.instance.option('cellDuration');
const cellDurationMs = cellDuration * MS_IN_HOUR;
const currentTime = new Date(currentDate as Date).getTime();
const roundTime = Math.round(currentTime / cellDurationMs) * cellDurationMs;
this.scheduler.instance.showAppointmentPopup({
startDate: new Date(roundTime),
endDate: new Date(roundTime + cellDurationMs),
}, true);
}
onAssigneesChange(event: DxSelectBoxTypes.ValueChangedEvent) {
const dataSource = this.scheduler.instance.option('dataSource');
const filter = event.value ? ['assigneeId', 'contains', event.value] : null;
dataSource.filter(filter);
this.scheduler.instance.option('dataSource', dataSource);
}
}
bootstrapApplication(AppComponent, {
providers: [
provideZoneChangeDetection({ eventCoalescing: true, runCoalescing: true }),
],
});
import { Injectable } from '@angular/core';
import { DataSource } from 'devextreme-angular/common/data';
export interface Appointment {
text: string;
startDate: number;
endDate: number;
allDay?: boolean;
assigneeId: number[];
recurrenceRule?: string;
}
export interface Assignee {
id: number;
text: string;
}
const addDays = (date, days) => new Date(new Date(date).setUTCDate(date.getUTCDate() + days));
const now = new Date(new Date().setUTCHours(0, 0, 0, 0));
const startOfTheWeek = addDays(now, -now.getUTCDay());
const currentDate = new Date(2025, 5, 10);
const currentStartOfTheWeek = addDays(currentDate, -currentDate.getUTCDay());
const appointments: Appointment[] = [
{
text: 'Website Re-Design Plan',
assigneeId: [4],
startDate: addDays(startOfTheWeek, 1).setUTCHours(16, 30),
endDate: addDays(startOfTheWeek, 1).setUTCHours(18, 30),
}, {
text: 'Book Flights to San Fran for Sales Trip',
assigneeId: [2],
startDate: addDays(startOfTheWeek, 2).setUTCHours(19),
endDate: addDays(startOfTheWeek, 2).setUTCHours(20),
allDay: true,
}, {
text: 'Install New Router in Dev Room',
assigneeId: [1],
startDate: addDays(startOfTheWeek, 2).setUTCHours(21, 30),
endDate: addDays(startOfTheWeek, 2).setUTCHours(22, 30),
}, {
text: 'Approve Personal Computer Upgrade Plan',
assigneeId: [3],
startDate: addDays(startOfTheWeek, 3).setUTCHours(17),
endDate: addDays(startOfTheWeek, 3).setUTCHours(18),
}, {
text: 'Final Budget Review',
assigneeId: [1],
startDate: addDays(startOfTheWeek, 3).setUTCHours(19),
endDate: addDays(startOfTheWeek, 3).setUTCHours(20, 35),
}, {
text: 'New Brochures',
assigneeId: [4],
startDate: addDays(startOfTheWeek, 3).setUTCHours(21, 30),
endDate: addDays(startOfTheWeek, 3).setUTCHours(22, 45),
}, {
text: 'Install New Database',
assigneeId: [2],
startDate: addDays(startOfTheWeek, 4).setUTCHours(16, 45),
endDate: addDays(startOfTheWeek, 4).setUTCHours(18, 15),
}, {
text: 'Approve New Online Marketing Strategy',
assigneeId: [4],
startDate: addDays(currentStartOfTheWeek, 1).setUTCHours(19),
endDate: addDays(currentStartOfTheWeek, 1).setUTCHours(21),
}, {
text: 'Upgrade Personal Computers',
assigneeId: [2],
startDate: addDays(currentStartOfTheWeek, 1).setUTCHours(22, 15),
endDate: addDays(currentStartOfTheWeek, 1).setUTCHours(23, 30),
}, {
text: 'Customer Workshop',
assigneeId: [3],
startDate: addDays(startOfTheWeek, 5).setUTCHours(18),
endDate: addDays(startOfTheWeek, 5).setUTCHours(19),
recurrenceRule: 'FREQ=WEEKLY;INTERVAL=1',
}, {
text: 'Prepare 2021 Marketing Plan',
assigneeId: [1],
startDate: addDays(currentStartOfTheWeek, 2).setUTCHours(18),
endDate: addDays(currentStartOfTheWeek, 2).setUTCHours(20, 30),
}, {
text: 'Brochure Design Review',
assigneeId: [4],
startDate: addDays(startOfTheWeek, 5).setUTCHours(21),
endDate: addDays(startOfTheWeek, 5).setUTCHours(22, 30),
}, {
text: 'Create Icons for Website',
assigneeId: [3],
startDate: addDays(currentStartOfTheWeek, 3).setUTCHours(17),
endDate: addDays(currentStartOfTheWeek, 3).setUTCHours(18, 30),
}, {
text: 'Upgrade Server Hardware',
assigneeId: [4],
startDate: addDays(currentStartOfTheWeek, 2).setUTCHours(16),
endDate: addDays(currentStartOfTheWeek, 2).setUTCHours(17, 30),
}, {
text: 'Submit New Website Design',
assigneeId: [1],
startDate: addDays(currentStartOfTheWeek, 5).setUTCHours(23, 30),
endDate: addDays(currentStartOfTheWeek, 6).setUTCHours(1),
}, {
text: 'Launch New Website',
assigneeId: [2],
startDate: addDays(currentStartOfTheWeek, 4).setUTCHours(19),
endDate: addDays(currentStartOfTheWeek, 4).setUTCHours(21),
},
];
const assignees: Assignee[] = [
{
text: 'Samantha Bright',
id: 1,
}, {
text: 'John Heart',
id: 2,
}, {
text: 'Todd Hoffman',
id: 3,
}, {
text: 'Sandra Johnson',
id: 4,
},
];
@Injectable()
export class Service {
getAppointmentsDataSource(): DataSource {
return new DataSource(appointments);
}
getAssignees(): Assignee[] {
return assignees;
}
getInitialCurrentDate(): Date {
return currentDate;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>DevExtreme Demo</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" />
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/26.1.5/css/dx.light.css" />
</head>
<body class="dx-viewport">
<div class="demo-container">
<demo-app>Loading...</demo-app>
</div>
<script src="https://cdn.jsdelivr.net/npm/zone.js@0.16.2/bundles/zone.umd.js"></script>
<script src="./bundle.js" type="module"></script>
</body>
</html>
To customize the Scheduler toolbar in your DevExtreme-powered app, add items to the toolbar.items[] array. DevExtreme Scheduler supports the following toolbar item types:
-
Predefined Controls
- "dateNavigator"
Displays a ButtonGroup component with next/previous buttons and a date interval button that invokes a dropdown calendar. Define options.items to customize the control. You can add new buttons, and specify button availability/order. - "viewSwitcher"
Switches between view types (day, week, month, and others). - "today"
A "Today" button (navigates to the current date).
- "dateNavigator"
-
DevExtreme Components
You can configure a DevExtreme component within a toolbar item element. In this demo, we extended the toolbar with a Button and SelectBox. -
Custom Controls
Specify items[].template to implement custom controls.
The default Scheduler toolbar displays "dateNavigator" and "viewSwitcher" predefined controls.