Your search did not match any results.
Scheduler

Limit the Appointment Count per Cell

Documentation

This example demonstrates how to limit the number of full-sized appointments per cell. On exceeding the limit, appointments are sent to the appointment collector where they are customized using the appointmentTooltipTemplate.

Copy to CodeSandBox
Apply
Reset
<dx-scheduler [dataSource]="appointmentsData" [views]="views" currentView="Auto Mode" [currentDate]="currentDate" appointmentTooltipTemplate="appointment-template" (onAppointmentDeleted)="onAppointmentDeleted()" [height]="650"> <dxi-view name="Auto Mode" type="month" maxAppointmentsPerCell="auto"> </dxi-view> <dxi-view name="Unlimited Mode" type="month" maxAppointmentsPerCell="unlimited"> </dxi-view> <dxi-view name="Numeric Mode" type="month" [maxAppointmentsPerCell]="2"> </dxi-view> <dxi-resource fieldExpr="roomId" label="room" [dataSource]="resourcesData" ></dxi-resource> <div *dxTemplate="let appointment of 'appointment-template'"> <div class="appointment-content"> <div class="appointment-badge" [ngStyle]="{ backgroundColor: getAppointmentColor(appointment.roomId) }">{{appointment.text[0]}}</div> <div class="appointment-text">{{appointment.text}}</div> <div class="appointment-dates"> {{(appointment.startDate | date : 'MMM d') + ' , ' + (appointment.startDate | date:'shortTime') + ' - ' + (appointment.endDate | date:'shortTime')}} </div> <dx-button class = "delete-appointment" icon="trash" (onClick)="deleteAppointment(appointment)"> </dx-button> </div> </div> </dx-scheduler>
import { NgModule, ViewChild, Component, enableProdMode } from '@angular/core'; import {BrowserModule} from '@angular/platform-browser'; import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; import {Appointment, Resource, Service} from './app.service'; import {DxSchedulerModule, DxSchedulerComponent, DxButtonModule} from 'devextreme-angular'; import Query from 'devextreme/data/query'; if(!/localhost/.test(document.location.host)) { enableProdMode(); } @Component({ selector: 'demo-app', templateUrl: 'app/app.component.html', styleUrls: ['app/app.component.css'], providers: [Service] }) export class AppComponent { @ViewChild(DxSchedulerComponent, { static: false }) scheduler: DxSchedulerComponent; appointmentsData: Appointment[]; currentDate: Date = new Date(2017, 4, 25); resourcesData: Resource[]; constructor(service: Service) { this.appointmentsData = service.getAppointments(); this.resourcesData = service.getResources(); } getAppointmentColor(id) { const data = Query(this.resourcesData) .filter(["id", "=", id]) .toArray(); return data.length ? data[0].color : ""; } deleteAppointment(appointment) { this.scheduler.instance.deleteAppointment(appointment); } onAppointmentDeleted() { this.scheduler.instance.hideAppointmentTooltip() } } @NgModule({ imports: [ BrowserModule, DxSchedulerModule, DxButtonModule ], declarations: [AppComponent], bootstrap: [AppComponent] }) export class AppModule { } platformBrowserDynamic().bootstrapModule(AppModule)
::ng-deep .appointment-content { width: 360px; } ::ng-deep .dx-popup-content .appointment-content { height: 40px; line-height: 20px; } ::ng-deep .appointment-badge { text-align: center; float: left; margin-right: 12px; color: white; width: 28px; height: 28px; font-size: 20px; line-height: 28px; border-radius: 28px; margin-top: 5px; display: flex; justify-content: center; flex-direction: column; padding-bottom: 2px; } ::ng-deep .appointment-dates { color: #959595; font-size: 12px; text-align: left; float: left; } ::ng-deep .appointment-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 270px; font-size: 15px; text-align: left; float: left; } ::ng-deep .delete-appointment { position: relative; border: none; box-shadow: none; height: 40px; } ::ng-deep .delete-appointment .dx-button-content { width: 40px; height: 40px; } ::ng-deep .delete-appointment.dx-state-hover, ::ng-deep .dx-list-item.dx-state-hover .dx-button { box-shadow: none; background-color: inherit; } ::ng-deep .delete-appointment .dx-icon-trash { color: #337ab7 !important; font-size: 23px !important; }
import { Injectable } from "@angular/core"; export class Appointment { text: string; roomId: number; startDate: Date; endDate: Date; } export class Resource { text: string; id: number; color: string; } let appointments: Appointment[] = [ { text: "Google AdWords Strategy", roomId: 1, startDate: new Date(2017, 4, 5, 9, 0), endDate: new Date(2017, 4, 5, 10, 30) }, { text: "New Brochures", roomId: 5, startDate: new Date(2017, 4, 5, 11, 30), endDate: new Date(2017, 4, 5, 14, 15) }, { text: "Brochure Design Review", roomId: 5, startDate: new Date(2017, 4, 5, 13, 15), endDate: new Date(2017, 4, 5, 16, 15) }, { text: "Website Re-Design Plan", roomId: 5, startDate: new Date(2017, 4, 5, 16, 45), endDate: new Date(2017, 4, 5, 11, 15) }, { text: "Rollout of New Website and Marketing Brochures", roomId: 2, startDate: new Date(2017, 4, 9, 8, 15), endDate: new Date(2017, 4, 9, 10, 45) }, { text: "Update Sales Strategy Documents", roomId: 3, startDate: new Date(2017, 4, 9, 12, 0), endDate: new Date(2017, 4, 9, 13, 45) }, { text: "Non-Compete Agreements", roomId: 3, startDate: new Date(2017, 4, 9, 8, 15), endDate: new Date(2017, 4, 9, 9, 0) }, { text: "Update NDA Agreement", roomId: 1, startDate: new Date(2017, 4, 10, 11, 45), endDate: new Date(2017, 4, 10, 13, 45) }, { text: "Update Employee Files with New NDA", roomId: 4, startDate: new Date(2017, 4, 18, 14, 0), endDate: new Date(2017, 4, 18, 16, 45) }, { text: "Submit Questions Regarding New NDA", roomId: 4, startDate: new Date(2017, 4, 18, 8, 0), endDate: new Date(2017, 4, 18, 9, 30) }, { text: "Submit Signed NDA", roomId: 4, startDate: new Date(2017, 4, 18, 12, 45), endDate: new Date(2017, 4, 18, 14, 0) }, { text: "Review Revenue Projections", roomId: 4, startDate: new Date(2017, 4, 25, 17, 15), endDate: new Date(2017, 4, 25, 18, 0) }, { text: "Comment on Revenue Projections", roomId: 1, startDate: new Date(2017, 4, 22, 9, 15), endDate: new Date(2017, 4, 22, 11, 15) }, { text: "Provide New Health Insurance Docs", roomId: 4, startDate: new Date(2017, 4, 22, 12, 45), endDate: new Date(2017, 4, 22, 14, 15) }, { text: "Review Changes to Health Insurance Coverage", roomId: 4, startDate: new Date(2017, 4, 25, 14, 15), endDate: new Date(2017, 4, 25, 15, 30) }, { text: "Review Training Course for any Ommissions", roomId: 4, startDate: new Date(2017, 4, 22, 14, 0), endDate: new Date(2017, 4, 22, 12, 0) }, { text: "Recall Rebate Form", roomId: 2, startDate: new Date(2017, 4, 23, 12, 45), endDate: new Date(2017, 4, 23, 13, 15) }, { text: "Create Report on Customer Feedback", roomId: 3, startDate: new Date(2017, 4, 23, 15, 15), endDate: new Date(2017, 4, 23, 17, 30) }, { text: "Review Customer Feedback Report", roomId: 3, startDate: new Date(2017, 4, 17, 16, 15), endDate: new Date(2017, 4, 17, 18, 30) }, { text: "Customer Feedback Report Analysis", roomId: 3, startDate: new Date(2017, 4, 17, 9, 30), endDate: new Date(2017, 4, 17, 10, 30) }, { text: "Prepare Shipping Cost Analysis Report", roomId: 3, startDate: new Date(2017, 4, 23, 12, 30), endDate: new Date(2017, 4, 23, 13, 30) }, { text: "Provide Feedback on Shippers", roomId: 3, startDate: new Date(2017, 4, 23, 14, 15), endDate: new Date(2017, 4, 23, 16, 0) }, { text: "Select Preferred Shipper", roomId: 1, startDate: new Date(2017, 4, 26, 17, 30), endDate: new Date(2017, 4, 26, 20, 0) }, { text: "Complete Shipper Selection Form", roomId: 5, startDate: new Date(2017, 4, 25, 8, 30), endDate: new Date(2017, 4, 25, 10, 0) }, { text: "Upgrade Server Hardware", roomId: 5, startDate: new Date(2017, 4, 26, 12, 0), endDate: new Date(2017, 4, 26, 14, 15) }, { text: "Upgrade Personal Computers", roomId: 5, startDate: new Date(2017, 4, 26, 14, 45), endDate: new Date(2017, 4, 26, 16, 30) } ]; let resources: Resource[] = [ { text: "Room 401", id: 1, color: "#bbd806" }, { text: "Room 402", id: 2, color: "#f34c8a" }, { text: "Room 403", id: 3, color: "#ae7fcc" }, { text: "Room 407", id: 4, color: "#ff8817" }, { text: "Room 409", id: 5, color: "#03bb92" } ]; @Injectable() export class Service { getAppointments(): Appointment[] { return appointments; } getResources(): Resource[] { return resources; } }
// In real applications, you should not transpile code in the browser. You can see how to create your own application with Angular 2 and DevExtreme here: // https://github.com/DevExpress/devextreme-angular/blob/master/README.md System.config({ transpiler: 'ts', typescriptOptions: { module: "commonjs", emitDecoratorMetadata: true, experimentalDecorators: true }, meta: { 'typescript': { "exports": "ts" } }, paths: { 'npm:': 'https://unpkg.com/' }, map: { 'ts': 'npm:plugin-typescript@8.0.0/lib/plugin.js', 'typescript': 'npm:typescript@3.4.5/lib/typescript.js', '@angular/core': 'npm:@angular/core@8.0.0/bundles/core.umd.js', '@angular/common': 'npm:@angular/common@8.0.0/bundles/common.umd.js', '@angular/compiler': 'npm:@angular/compiler@8.0.0/bundles/compiler.umd.js', '@angular/platform-browser': 'npm:@angular/platform-browser@8.0.0/bundles/platform-browser.umd.js', '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic@8.0.0/bundles/platform-browser-dynamic.umd.js', '@angular/router': 'npm:@angular/router@8.0.0/bundles/router.umd.js', '@angular/forms': 'npm:@angular/forms@8.0.0/bundles/forms.umd.js', '@angular/common/http': 'npm:@angular/common@8.0.0/bundles/common-http.umd.js', 'tslib': 'npm:tslib/tslib.js', 'rxjs': 'npm:rxjs@6.3.3', 'rxjs/operators': 'npm:rxjs@6.3.3/operators', 'devextreme': 'npm:devextreme@19.1', 'jszip': 'npm:jszip@3.1.3/dist/jszip.min.js', 'quill': 'npm:quill@1.3.6/dist/quill.js', 'devexpress-diagram': 'npm:devexpress-diagram', 'devextreme-angular': 'npm:devextreme-angular@19.1' }, packages: { 'app': { main: './app.component.ts', defaultExtension: 'ts' }, 'devextreme': { defaultExtension: 'js' }, 'rxjs': { main: 'index.js', defaultExtension: 'js' }, 'rxjs/operators': { main: 'index.js', defaultExtension: 'js' }, 'devextreme-angular': { main: 'index.js', defaultExtension: 'js' } } });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <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=1.0" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.1.6/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.1.6/css/dx.light.css" /> <script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script> <script src="https://unpkg.com/zone.js@0.6.25/dist/zone.js"></script> <script src="https://unpkg.com/reflect-metadata@0.1.3/Reflect.js"></script> <script src="https://unpkg.com/systemjs@0.21.3/dist/system.js"></script> <script src="config.js"></script> <script> System.import('app').catch(console.error.bind(console)); </script> </head> <body class="dx-viewport"> <div class="demo-container"> <demo-app>Loading...</demo-app> </div> </body> </html>