Blazor scheduler and disabling days for the public holidays

Greeting,


I wonder if you can direct me on how to accomplish the following things on the Blazor scheduler.


1. In the monthly view of the scheduler, present the cell blocks for the list of dates that contains dates for the public holidays differently (e.g. in a different colour) and prevent any event to be created for those cell blocks when clicking on them.


2. When creating a recurring event, if the duration of that event contains any dates from the list of dates that contains dates for the public holidays, the dates should be excluded from that recurring event duration.



Thanks in advance!


BR,

Afshin


1 Reply 1 reply marked as answer

RM Ruksar Moosa Sait Syncfusion Team April 11, 2022 02:56 PM UTC

Hi Afshin,


We have prepared a sample to accomplish your requirement.

1. Adding a custom class to the respective dates in OnRenderCell method

2. Restricting the event creation in OnEventRendered method.

3. Restricting the opening of popups in OnPopupOpen method.


DateTime[] dateCollection = new DateTime[]

        {

            new DateTime(2022, 1, 10),

            new DateTime(2022, 1, 13),

            new DateTime(2022, 1, 14)

        };

    public void OnRenderCell(RenderCellEventArgs args)

    {

        var item = args.Date;

        bool exist = dateCollection.Any (d => d.Month == item.Month && d.Day == item.Day);

        if (exist)

        {

            args.CssClasses = new List<string>(CellCustomClass);

        }     

    }

    public void OnEventRendered(EventRenderedArgs<AppointmentData> args)

    {

        var item = args.Data.StartTime;

        bool exist = dateCollection.Any (d => d.Month == item.Month && d.Day == item.Day);

        if (exist)

        {

            args.Cancel = true;

        } 

    }

    public void OnPopupOpen(PopupOpenEventArgs<AppointmentData> args)

    {

        var item = args.Data.StartTime;

        bool exist = dateCollection.Any (d => d.Month == item.Month && d.Day == item.Day);

        if (exist)

        {

            args.Cancel = true;

        }

    }


Kindly try the attached sample and let us know if this meets your requirement.


Regards,

Ruksar Moosa Sait


Attachment: PreventCRUDforDateCollection_d7b88d77.zip

Marked as answer
Loader.
Up arrow icon