Skip to main content

DxDateEditSettings.CustomDisabledDate Event

Allows you to disable selection of individual dates in the date editor.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

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

You can disable specific dates in the date editor’s calendar. These dates are grayed out.

The date editor’s calendar disables dates that are out of the [MinDate; MaxDate] range. To disable dates based on custom logic, handle the CustomDisabledDate event. This event is raised each time a day cell is rendered.

Use the Date event argument’s property to determine the processed day. The IsDisabled property specifies whether the processed date is available.

The following code snippet disables Saturdays, Sundays, and a set of custom holidays in the date editor.

<DxGrid Data="@employees" EditMode="GridEditMode.EditRow">
    <Columns>
        <DxGridCommandColumn />
        <DxGridDataColumn FieldName="FirstName" />
        <DxGridDataColumn FieldName="LastName" />
        <DxGridDataColumn FieldName="HireDate" >
             <EditSettings>
                <DxDateEditSettings CustomDisabledDate="@OnCustomDisabledDate" />
            </EditSettings>
        </DxGridDataColumn>
        <DxGridDataColumn FieldName="Email" />
    </Columns>
</DxGrid>

@code {
    Employee[]? employees;
    protected override async Task OnInitializedAsync() {
        employees = await EmployeeData.GetData();
    }
    void OnCustomDisabledDate(CalendarCustomDisabledDateEventArgs args) {
        args.IsDisabled = args.Date.DayOfWeek == DayOfWeek.Saturday
            || args.Date.DayOfWeek == DayOfWeek.Sunday 
            || GetHolidays().Exists(d => d.Date == args.Date.Date);
    }
    List<DateTime> GetHolidays() {
        return new List<DateTime>() { 
            new DateTime(2023, 05, 01),
            new DateTime(2023, 05, 02),
            new DateTime(2023, 05, 15),
            new DateTime(2023, 05, 23)
        };
    }
}

Grid - WeekNumberRule

In scroll picker mode, the date editor shows a notification message each time a user tries to navigate to a disabled date. To customize the notification text, use the DisabledDateNotificationText property.

Implements

See Also