how to check if a event is conflicting with other existing scheduled events

How to block creating an event (Test 1), if it conflicts with the existing event (Test).





1 Reply

RV Ravikumar Venkatesan Syncfusion Team June 6, 2023 01:03 PM UTC

Hi Selva,


You can block creating appointments if there is already an appointment with the help of the isSlotAvailable method and actionBegin event of the Schedule as shown in the below code snippet. Refer to the shared UG and API link for more information.


[index.cshtml]

@using Syncfusion.EJ2.Schedule

 

@Html.EJS().Schedule("schedule").Width("100%").Height("550px").CurrentView(View.Day).ActionBegin("onActionBegin").Render()

 

<script type="text/javascript">

    function onActionBegin(args) {

        var scheduleObj = document.querySelector('.e-schedule').ej2_instances[0];

        if ((args.requestType === 'eventCreate' || args.requestType === 'eventChange') && args.data.length > 0) {

            args.cancel = !scheduleObj.isSlotAvailable(args.data[0]);

        }

    }

</script>


UG: https://ej2.syncfusion.com/aspnetmvc/documentation/schedule/appointments#restricting-event-creation-on-specific-time-slots

API:

actionBegin: https://ej2.syncfusion.com/javascript/documentation/api/schedule/#actionbegin

isSlotAvailable: https://ej2.syncfusion.com/javascript/documentation/api/schedule/#isslotavailable


Regards,

Ravikumar Venkatesan


Attachment: ej2_mvc_schedule_isslotavailable_ebdf508c.zip

Loader.
Up arrow icon