Is there any way to check if a event is conflicting with other existing scheduled events?

I was trying to block creating an event if it conflicts with other existing scheduled events time frames, considering both new and existing events be recurring events. Is there any helper method available in the Syncfusion framework?


1 Reply

VD Vinitha Devi Murugan Syncfusion Team August 4, 2021 06:31 AM UTC

Hi Khan, 
 
Greetings from Syncfusion Support. 
 
We have validated your reported query “I was trying to block creating an event if it conflicts with other existing scheduled events time frames, considering both new and existing events be recurring events. Is there any helper method available in the Syncfusion framework.” and achieved your requirement by making use of actionBegin event and isSlotAvailable public method with below code. We have prepared the below sample for your reference.  
 
 
 
function onActionBegin(args) { 
    ifargs.requestType === "eventCreate" || args.requestType === "eventChange" ) { 
    let data = args.data instanceof Array ? args.data[0] : args.data; 
    let scheduleObj = (document.querySelector(".e-schedule")).ej2_instances[0]; 
    if (! ej.base.isNullOrUndefined(data.RecurrenceRule)) { 
        let occurrences = (scheduleObj).eventBase.generateOccurrence(data); 
        for (let i = 0i < occurrences.lengthi++) { 
            // Get the timeslot and check if there is already an event 
            let filteredEvents = (scheduleObj).eventBase.filterEvents( 
                occurrences[i].StartTime, 
                occurrences[i].EndTime 
            ); 
            if (filteredEvents.length > 0) { 
                args.cancel = true; 
                break; 
            } 
        } 
    } else { 
        args.cancel = !scheduleObj.isSlotAvailable(data); 
    } 
} 
} 
 
Kindly try with the above sample and get back to us if you need any further assistance. 
 
Regards, 
Vinitha 


Loader.
Up arrow icon