Hi,
I've been looking around the samples provided for ways to stop users from creating multiple appointments in some resources. I'm aware of the methods contained in actionBegin and popupOpen.
I'm already checking if the slot is available on popupOpen. Still, a user could have selected a free spot, and then change the start/end to a conflicting time period.
However, cancelling actionBegin isn't a great option - if a user has made extensive choices, put in all data in all fields and actionBegin is cancelled, I cannot "re-open" the editor with an error message whilst keeping all the information there.
I'd prefer to validate the availability of a slot beforehand. So far I have:
Validation Rule for StartTime:
var validationSlotAvailable = new Dictionary<string, object>() { { "required", new string[] { "isSlotAvailable", "Slot must be available"} } };
JS function:
function isSlotAvailable(startTimeElement) {
let scheduleObj = document.getElementById('YachtEJ2').ej2_instances[0];
let startTime = startTimeElement.element.value;
let endTime = startTimeElement.element.form.getElementsByClassName("e-end").EndTime.value; // <-- Is there a better way to obtain this?
// let groupIndex = ? // how can I obtain the groupIndex from the editor?
return scheduleObj.isSlotAvailable(startTime, endTime, groupIndex);
}
I'm not quite clear how I can obtain the group index, or better yet, the whole "args.data" that is available in popupOpen. I'd be grateful if you could help me out.
Thanks!