DxCalendarBase.CustomDisabledDate Event

Allows you to disable selection of individual dates in the DxCalendar component based on custom logic.

Namespace: DevExpress.Blazor.Base

Assembly: DevExpress.Blazor.dll

Declaration

[Parameter]
public Action<CalendarCustomDisabledDateEventArgs> CustomDisabledDate { get; set; }

Event Data

The CustomDisabledDate event's data class is CalendarCustomDisabledDateEventArgs. The following properties provide information specific to this event:

Property Description
Date Gets a DateTime object that corresponds to the processed date.
IsDisabled Specifies whether the processed date can be selected.

Remarks

The CustomDisabledDate event is raised each time a day cell is rendered. You can use the Date event argument's property to determine the processed day. The IsDisabled property specifies whether the processed date is available for selection.

<DxCalendar CustomDisabledDate="@OnCustomDisabledDate">
</DxCalendar>

@code {
    void OnCustomDisabledDate(CalendarCustomDisabledDateEventArgs args) {
        args.IsDisabled = args.Date < DateTime.Today.AddDays(-20) || GetDisabledDates().Exists(d => DaysEqual(d, args.Date));
    }
    bool DaysEqual(DateTime date1, DateTime date2) {
        return (date1.Year == date2.Year && date1.DayOfYear == date2.DayOfYear);
    }
    List<DateTime> GetDisabledDates() {
        DateTime baseDate = DateTime.Today;
        return new List<DateTime>() { baseDate.AddDays(-9), baseDate.AddDays(-4), baseDate.AddDays(-3), baseDate.AddDays(3), baseDate.AddDays(5), baseDate.AddDays(6), baseDate.AddDays(15) };
    }

Calendar Disabled Dates

NOTE

Online Demo: Calendar - Disabled Dates

See Also