Angular Scheduler - Group Appointments by Resources

To group appointments by resources, assign an array to the groups property. Each element of this array is fieldExpr of a resource kind. Note that the resource headers' order depends on the resources' order in the resources array.

HTML
TypeScript
  • <dx-scheduler
  • [dataSource]="appointments"
  • [groups]="['roomId', 'teacherId']"> <!-- Groups appointments by rooms and by teachers -->
  • <dxi-resource
  • fieldExpr="roomId"
  • [dataSource]="rooms">
  • </dxi-resource>
  • <dxi-resource
  • fieldExpr="teacherId"
  • [dataSource]="teachers">
  • </dxi-resource>
  • </dx-scheduler>
  • import { DxSchedulerModule } from "devextreme-angular";
  • // ...
  • export class AppComponent {
  • // ...
  • appointments = [{
  • roomId: 1,
  • teacherId: 2,
  • text: "Meeting",
  • // ...
  • },
  • // ...
  • ];
  • rooms = [
  • // Resource instances
  • {
  • id: 1, // Resource identifier
  • text: "Room101", // Resource name
  • color: "red" // Color for indicating appointments that use this resource
  • },
  • { id: 2, text: "Room102", color: "green" },
  • // ...
  • ];
  • teachers = [
  • // Resource instances
  • { id: 1, text: "John Heart", color: "yellow" },
  • { id: 2, text: "Sandra Johnson", color: "blue" },
  • // ...
  • ];
  • // ...
  • }
  • @NgModule({
  • imports: [
  • // ...
  • DxSchedulerModule
  • ],
  • // ...
  • })

Scheduler Grouping by Resources

You can change resource headers' orientation in an individual view using the views.groupOrientation property. In the following code, the orientation in the day view is "vertical", so that resource headers are arranged in a column:

TypeScript
HTML
  • import { DxSchedulerModule } from "devextreme-angular";
  • // ...
  • export class AppComponent {
  • // ...
  • }
  • @NgModule({
  • imports: [
  • // ...
  • DxSchedulerModule
  • ],
  • // ...
  • })
  • <dx-scheduler ... >
  • <dxi-view type="month"></dxi-view>
  • <dxi-view
  • type="day"
  • groupOrientaion="vertical">
  • </dxi-view>
  • </dx-scheduler>

View Demo

See Also