We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Prevent moving events to a resource if already has an event

Hi,

Is it possible to prevent the user dragging an event to a resource if that resource already has an event for any part of the time of that event?


So given this situation we should not be able to move the event (2 Guests Jim) to the resource (for the times shown) that already has an event (2 Guests Bob).  

Thanks,

Alex



3 Replies

SR Swathi Ravi Syncfusion Team February 8, 2023 01:12 PM UTC

Hi Alex,


You can prevent the appointments from being added on the resource has same date range by using the IsSlotAvailable method in the OnActionBegin, as shown in the below snippet.


UG: https://blazor.syncfusion.com/documentation/scheduler/appointments#restricting-event-creation-on-specific-time-slots

Api: https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Schedule.SfSchedule-1.html#Syncfusion_Blazor_Schedule_SfSchedule_1_IsSlotAvailableAsync_System_DateTime_System_Nullable_System_DateTime__System_Nullable_System_Int32__

                https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Schedule.ScheduleEvents-1.html#Syncfusion_Blazor_Schedule_ScheduleEvents_1_OnActionBegin


[index.razor]

<SfSchedule @ref="ScheduleRef" TValue="AppointmentData" Height="550px" @bind-SelectedDate="@CurrentDate">

    <ScheduleEvents TValue="AppointmentData" OnActionBegin="OnActionBegin"></ScheduleEvents>

</SfSchedule>

public async Task OnActionBegin(ActionEventArgs<AppointmentData> args)

    {

        bool availability = true;

        if (args.ActionType == ActionType.EventChange)

        {

            var records = args.AddedRecords ?? args.ChangedRecords;

            if (records == null)

            {

                return;

            }

            availability = await ScheduleRef.IsSlotAvailableAsync(records.First());

        }

        args.Cancel = !availability;

    }



Regards,

Swathi Ravi


Attachment: blazorschedulerisslotavailable_2523b12e.zip


AL Alex February 9, 2023 01:13 PM UTC

Thanks will take a look



RV Ravikumar Venkatesan Syncfusion Team February 10, 2023 01:18 PM UTC

Alex,


You are welcome. Let us know if you need any further assistance on this.


Loader.
Live Chat Icon For mobile
Up arrow icon