Disable dates on RadCalendar

1 Answer 41 Views
Calendar, DateTimePicker, TimePicker and Clock
Carl
Top achievements
Rank 1
Iron
Iron
Iron
Carl asked on 17 Jun 2024, 12:48 PM

Using RadCalendar and I thought is would be simple

I want all dates in the past to be disabled and I thought this would do it:

        private void radCalendar1_ElementRender(object sender, RenderElementEventArgs e)

        {
            if (e.Day.Date < DateTime.Now)
                e.Day.Disabled = true;
        }

Th goals is to have it look like this but it seems to have no effect and I can selected dates that the code set as disabled.

What am I missing?

Thanks

Carl

1 Answer, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 18 Jun 2024, 08:49 AM

Hello, Carl,

You are on the right path but should disable the visual element and use e.Element.Enabled property. RadCalendarDay is the logical object. Please refer to the updated code snippet:

private void RadCalendar1_ElementRender(object sender, RenderElementEventArgs e)
{
    if (e.Day.Date < DateTime.Now)
        e.Element.Enabled = false; 
}

Thus, the disabled elements will look gray out and cannot be clicked:

I hope this helps. If you have any other questions do not hesitate to contact me.

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Carl
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or