Back to Devexpress

DxGrid.CustomizeDataRowEditor Event

blazor-devexpress-dot-blazor-dot-dxgrid-9038897a.md

latest2.9 KB
Original Source

DxGrid.CustomizeDataRowEditor Event

Allows you to customize a cell editor in a data row.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[Parameter]
public Action<GridCustomizeDataRowEditorEventArgs> CustomizeDataRowEditor { get; set; }

Parameters

TypeDescription
GridCustomizeDataRowEditorEventArgs

An object that contains data for this event.

|

Remarks

The Grid generates and configures cell editors for individual columns based on associated data types. You can use the EditSettings property to customize a column’s editor settings. The Grid displays these cell editors in the filter row and in data rows during edit operations.

Handle the CustomizeDataRowEditor event to customize a data row editor separately from the filter row editor.

The following code snippet handles the CustomizeDataRowEditor event to customize the HireDate column editor in two ways:

  • Limit available hire dates for new employees.
  • Prohibit hire date modification for existing employees.
razor
<DxGrid Data="@employees" PageSize="4" ShowFilterRow="true" EditMode="GridEditMode.EditRow"
        CustomizeDataRowEditor="OnCustomizeDataRowEditor">
    <Columns>
        <DxGridCommandColumn />
        <DxGridDataColumn FieldName="FirstName" />
        <DxGridDataColumn FieldName="LastName" />
        <DxGridDataColumn FieldName="HireDate" />
        <DxGridDataColumn FieldName="Email" />
    </Columns>
</DxGrid>

@code {
    Employee[]? employees;
    protected override async Task OnInitializedAsync() {
        employees = await EmployeeData.GetData();
    }
    void OnCustomizeDataRowEditor(GridCustomizeDataRowEditorEventArgs e) {
        if (e.FieldName == "HireDate") {
            var HireDateSettings = e.EditSettings as IDateEditSettings;
            if (e.IsNewRow) {
                // Limit the available hire date for new employees two weeks ahead.
                HireDateSettings.MinDate = @DateTime.Today;
                HireDateSettings.MaxDate = @DateTime.Today.AddDays(14);
            } else {
                // Disable the hire date editing.
                HireDateSettings.Enabled = false;
                HireDateSettings.ShowDropDownButton = false;
            }
        }
    }
}

See Also

DxGrid Class

DxGrid Members

DevExpress.Blazor Namespace