Skip to main content

DxDateEditSettings.MaxDate Property

Specifies the maximum date that can be selected in the date editor.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public DateTime MaxDate { get; set; }

Property Value

Type Description
DateTime

The maximum date.

Remarks

Use the MinDate and MaxDate properties to specify a range of available dates. Note that the maximum date should be greater than the minimum date; otherwise, an exception occurs. The date editor’s calendar disables dates that are out of the range and navigation arrows for them. If a user types a date outside this range, the date editor keeps the previously selected date.

The default minimum and maximum values are DateTime.MinValue and DateTime.MaxValue.

In the following code snippet, the hire date can be specified two weeks in advance and only for new employees.

@inject EmployeeService EmployeeData

<DxGrid @ref="grid" Data="@employees" PageSize="4" KeyFieldName="ID"
        EditMode="GridEditMode.EditRow" EditStart="OnEditStart">
    <Columns>
        <DxGridCommandColumn />
        <DxGridDataColumn FieldName="FirstName" />
        <DxGridDataColumn FieldName="LastName" />
        <DxGridDataColumn FieldName="BirthDate" />
        <DxGridDataColumn FieldName="HireDate" >
            <EditSettings>
                <DxDateEditSettings MinDate="@DateTime.Today" 
                                    MaxDate="@DateTime.Today.AddDays(14)" />
            </EditSettings>
        </DxGridDataColumn>
        <DxGridDataColumn FieldName="Email" />
    </Columns>
</DxGrid>

@code {
    IGrid grid { get; set; }
    Employee[]? employees;
    protected override async Task OnInitializedAsync() {
        employees = await EmployeeData.GetData();
    }
    void OnEditStart(GridEditStartEventArgs e) {
        var settingsHireDate = grid.GetColumnEditSettings<IDateEditSettings>("HireDate");
        grid.BeginUpdate();
        // Allows users to edit the hire date for new employees only
        settingsHireDate.Enabled = e.IsNew;
        settingsHireDate.ShowDropDownButton = e.IsNew;
        grid.EndUpdate();
    }
}

Edit a Row

Date Edit in Grid

Create a Row

Date Edit in Grid

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

To change the maximum date at runtime, use the IDateEditSettings.MaxDate property instead.

Implements

See Also