I would like to manually capture the edit and delete events. I have tried popup close but it has only one method and none of them label that event as delete, add or edit
Here is the current code of what I am doing to capture popup close
Hi David,
You can achieve your requirement by capturing the target in the popupClose
event or using the actionBegin event in the schedule to meet your
requirements. The attached code snippet and the following example illustrate the
solution. Please give it a try, and let us know if you need any further
assistance.
Sample: https://stackblitz.com/edit/capture-edit-delete-events-scheduler-wwivqb?file=src%2Fapp.component.html,src%2Fapp.component.ts
[app.component.html]
|
<style> .control-section{ margin-top: 100px; }
</style> <div class="control-section"> <div class="col-lg-9 content-wrapper"> <ejs-schedule #scheduleObj width='100%' height='650px' [selectedDate]="selectedDate" [eventSettings]="eventSettings" [(currentView)]="scheduleView" (actionBegin)="onActionBegin($event)" (popupClose)="onPopupClose($event)"> <e-views> <e-view option="Day"></e-view> <e-view option="Week"></e-view> <e-view option="WorkWeek"></e-view> <e-view option="Month"></e-view> </e-views> </ejs-schedule> </div> </div>
|
[app.component.ts]
|
export class AppComponent { @ViewChild('scheduleObj') public scheduleObj: ScheduleComponent;
public selectedDate: Date = new Date(2021, 1, 15); public eventSettings: EventSettingsModel = { dataSource: extend([], zooEventsData, null, true) as Record<string, any>[] }; public scheduleView: View = 'Week'; public datas: string[] = ['Day', 'Week', 'WorkWeek', 'Month'];
public onActionBegin(args: ActionEventArgs): void { if (args.requestType === "eventChange") {
// Handle the code if "save" button is clicked.
} else if (args.requestType === "eventRemove") {
// Handle the code if "save" button is clicked.
} }
public onPopupClose(args: PopupCloseEventArgs): void { if (args.type === 'Editor') { if (args.event) { if ((args.event.target as any).classList.contains('e-event-save')) { // Handle the code if "save" button is clicked.
} else if ((args.event.target as any).classList.contains('e-event-delete')) { // Handle the code if "delete" button is clicked.
} else if ((args.event.target as any).classList.contains('e-event-cancel') || ((args.event.target as any).classList.contains('e-icon-dlg-close'))) { // Handle the code if "cancel" button is clicked. } } }
} }
|
Regards,
Ashok
This is good thank you. One last issue I am trying to load events manually in the ng onit function and this is not working as expected. None of the events are getting loaded. How can I get the events to load during ng onit
https://stackblitz.com/edit/capture-edit-delete-events-scheduler-zt7hgz?file=src%2Fapp.component.html,src%2Fapp.component.ts
Hi David,
The Schedule doesn't
render initially, making it impossible to set data values directly in the ngOnInit()
method. Instead, you can use the code below to add data in the ngOnInit()
function. Please give it a try and let us know if you need any further
assistance.
Sample: https://stackblitz.com/edit/capture-edit-delete-events-scheduler-rp4u5d?file=src%2Fapp.component.html,src%2Fapp.component.ts
|
export class AppComponent implements OnInit {
@ViewChild('scheduleObj') public scheduleObj: ScheduleComponent;
public selectedDate: Date = new Date(2021, 1, 15); public eventSettings: EventSettingsModel = { dataSource: []}; public scheduleView: View = 'Week'; public datas: string[] = ['Day', 'Week', 'WorkWeek', 'Month'];
ngOnInit(): void { this.eventSettings.dataSource = zooEventsData
}
|
Regards,
Ashok