|
| 1 | +import { Component, ViewChild } from '@angular/core'; |
| 2 | +import { EventSettingsModel, ScheduleComponent, ToolbarActionArgs } from '@syncfusion/ej2-angular-schedule'; |
| 3 | +import { ItemModel } from '@syncfusion/ej2-navigations'; |
| 4 | +import { scheduleData } from './data'; |
| 5 | +import { SelectedEventArgs } from '@syncfusion/ej2-angular-inputs'; |
| 6 | +@Component({ |
| 7 | + selector: 'app-root', |
| 8 | + templateUrl: './app.component.html', |
| 9 | + styleUrls: ['./app.component.css'] |
| 10 | +}) |
| 11 | +export class AppComponent { |
| 12 | + title = 'myangularproject'; |
| 13 | + @ViewChild('scheduler') schedulerObj !: ScheduleComponent; |
| 14 | + public selectedDate: Date = new Date(2023, 9, 9); |
| 15 | + public eventSettings: EventSettingsModel = { dataSource: scheduleData }; |
| 16 | + public buttons = {browse: 'Choose file'} |
| 17 | + public onActionBegin(args: ToolbarActionArgs){ |
| 18 | + if(args.requestType === "toolbarItemRendering"){ |
| 19 | + let exportItem: ItemModel = { |
| 20 | + text: 'Export Calendar', |
| 21 | + click: this.onExportClick.bind(this) |
| 22 | + } |
| 23 | + let printItem: ItemModel = { |
| 24 | + text: 'Print', |
| 25 | + prefixIcon: 'e-icon e-print', |
| 26 | + click: this.onPrintClick.bind(this) |
| 27 | + } |
| 28 | + args.items?.push(exportItem, printItem); |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + public onExportClick(){ |
| 33 | + this.schedulerObj.exportToICalendar('schedulerEvents'); |
| 34 | + } |
| 35 | + |
| 36 | + public onPrintClick(){ |
| 37 | + this.schedulerObj.print({ height: 'Auto', width: 'Auto'}); |
| 38 | + } |
| 39 | + |
| 40 | + public onFileSelect(args: SelectedEventArgs){ |
| 41 | + let file = (args.event.target as HTMLInputElement)?.files?.[0] as Blob; |
| 42 | + this.schedulerObj.importICalendar(file); |
| 43 | + } |
| 44 | +} |
0 commit comments