Skip to main content
All docs
V26.1
  • DxGridDataColumn.CellEditTemplate Property

    Allows you to replace an automatically generated editor with custom content in the column’s edit cell.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.Grid.v26.1.dll

    NuGet Package: DevExpress.Blazor

    Declaration

    [Parameter]
    public RenderFragment<GridDataColumnCellEditTemplateContext> CellEditTemplate { get; set; }

    Property Value

    Type Description
    RenderFragment<GridDataColumnCellEditTemplateContext>

    The template for the data column’s edit cell.

    Remarks

    In EditRow and EditCell edit modes, the Grid displays automatically generated inline editors in the edited row. Editor types depend on the data types of the corresponding column fields.

    You can customize cell editors using editor settings or a cell template. Choose between these options based your scenario:

    Task Recommended Option
    Display a standard cell editor[1] Editor Settings
    Customize standard editor appearance or behavior[1] Editor Settings
    Use any DevExpress or third-party component as a cell editor Cell Edit Template
    Implement advanced data binding Cell Edit Template
    Handle editor events Cell Edit Template
    Add custom buttons to an editor Cell Edit Template
    Focus an editor programmatically Cell Edit Template

    The column’s CellEditTemplate allows you to display custom content in the data column’s edit cell. To define a common cell edit template for all data columns, use the Grid’s DataColumnCellEditTemplate. Both templates include the context parameter that contains DataColumn and DataItem objects. The context’s Grid property allows you to access the Grid and its extensive API.

    The following code snippet displays a date editor with custom command buttons in an edit cell:

    Blazor Grid Inline Edit Row

    @using Microsoft.EntityFrameworkCore
    @inject IDbContextFactory<NorthwindContext> NorthwindContextFactory
    
    <DxGrid @ref="Grid"
            Data="Data"
            KeyFieldName="EmployeeId"
            EditMode="GridEditMode.EditRow">
        <Columns>
            <DxGridCommandColumn />
            <DxGridDataColumn FieldName="FirstName" />
            <DxGridDataColumn FieldName="LastName" />
            <DxGridDataColumn FieldName="Title" />
            <DxGridDataColumn FieldName="HireDate">
                <CellEditTemplate>
                    @{
                        var employee = (Employee)context.EditModel;
                    }
                    <DxDateEdit @bind-Date="@employee.HireDate">
                        <Buttons>
                            <DxEditorButton IconCssClass="editor-icon editor-icon-chevron-left-small"
                                            Tooltip="Previous date"
                                            Position="@EditorButtonPosition.Left"
                                            Click="@(_ => employee.HireDate = employee.HireDate?.AddDays(-1))" />
                            <DxEditorButton IconCssClass="editor-icon editor-icon-chevron-right-small"
                                            Tooltip="Next date"
                                            Position="@EditorButtonPosition.Right"
                                            Click="@(_ => employee.HireDate = employee.HireDate?.AddDays(1))" />
                        </Buttons>
                    </DxDateEdit>
                </CellEditTemplate>
            </DxGridDataColumn>
        </Columns>
    </DxGrid>
    
    @code {
        IEnumerable<object> Data { get; set; }
        NorthwindContext Northwind { get; set; }
        DateTime DateTimeValue { get; set; } = DateTime.Today;
        bool CalendarVisible { get; set; }
    
        void OnChangeDayButtonClick(bool isAdd) {
            CalendarVisible = false;
            DateTimeValue = DateTimeValue.AddDays(isAdd ? 1 : -1);
        }
        // ...
    }
    

    For additional information about templates in the Grid component, refer to the following topic: Templates in Blazor Grid.

    Implements

    Footnotes
    1. Standard editors include DevExpress Blazor CheckBox, ComboBox, Date Edit, Masked Input, Memo, Spin Edit, Text Box, and TimeEdit components.

    See Also