Dear Customer,
Thanks for Contacting Syncfusion support.
We have prepared the sample to achieve your requirement for
preventing the overlapping appointment creation by using our public method
“isSlotAvailable” and “actionBegin” event, which can be downloaded from the
following location.
http://www.syncfusion.com/downloads/support/forum/137662/ze/SchedulePreventingAppCreation2031637543
In the above sample, we have prevented the appointment
creation within the onActionBegin method by setting the args.cancel
value as true. Please refer to the following code example used in the
above sample.
<Code>
app.component.html:
<ejs-schedule width="100%" height="550px" [eventSettings]='eventSettings' [selectedDate]="selectedDate" (actionBegin)="onActionBegin($event)"></ejs-schedule>
app.component.ts:
onActionBegin(args: ActionEventArgs) { // Here checking
the appointment creation time is available or not, and proceed to create the
appointment if available.
if (args.requestType === "eventCreate") {
let eventData: any = args.data;
let scheduleElement: Element = document.querySelector('.e-schedule');
let scheduleObj: Schedule = ((scheduleElement as EJ2Instance).ej2_instances[0] as Schedule);
if (!scheduleObj.isSlotAvailable(eventData.StartTime, eventData.EndTime)) // Here the
isSlotAvailable public method used to check for the availability
of the mentioned time slot
args.cancel = true;
}
}
</Code>
Also, we request you to look into our below UG link to know
about the isSlotAvailable method and actionBegin event.
isSlotAvialable: https://ej2.syncfusion.com/16.1.37/documentation/schedule/api-schedule.html?lang=typescript#isslotavailable
actionBegin: https://ej2.syncfusion.com/16.1.37/documentation/schedule/api-schedule.html?lang=typescript#actionbegin
Kindly try with the above sample and let us know if you need
any further assistance on this.
Regards,
|
onActionBegin(args: ActionEventArgs) {
if (args.requestType === "eventCreate" || args.requestType === "eventChange") {
let eventData: any = !isNullOrUndefined(args.data[0]) ? args.data[0] : args.data;
let scheduleElement: Element = document.querySelector('.e-schedule');
let scheduleObj: Schedule = ((scheduleElement as EJ2Instance).ej2_instances[0] as Schedule);
if (!scheduleObj.isSlotAvailable(eventData.StartTime, eventData.EndTime))
args.cancel = true;
}
}
|
|
public onActionBegin(args: ActionEventArgs): void {
if (
args.requestType === "eventCreate" ||
args.requestType === "eventChange"
) {
let eventData: any = !isNullOrUndefined(args.data[0])
? args.data[0]
: args.data;
args.cancel = !this.scheduleObj.isSlotAvailable(eventData);
}
}
public onPopupOpen(args: PopupOpenEventArgs): void {
if (args.type == "QuickInfo" || args.type == "Editor") {
args.cancel = !this.scheduleObj.isSlotAvailable(args.data);
}
} |