Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TreeListCommandColumnCellDisplayTemplateContext.EditEnabled Property

Returns whether the Edit operation is available for a row from a remote data source.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public bool EditEnabled { get; }

#Property Value

Type Description
Boolean

true if the edit operation is available; otherwise, false.

#Remarks

A command column displays built-in CRUD-related buttons (New, Edit, and Delete). Define the column’s HeaderTemplate and CellDisplayTemplate to implement custom command elements.

Add, Edit, and Delete operations may be temporarily unavailable if you bind the TreeList to the GridDevExtremeDataSource or load data on demand. Use the following template parameters to specify the enabled or disabled state for custom command elements:

Razor
@inject IEmployeeTaskDataProvider EmployeeTaskDataProvider

<DxTreeList Data="TreeListData"
            KeyFieldName="Id"
            ParentKeyFieldName="ParentId"
            EditModelSaving="TreeList_EditModelSaving"
            DataItemDeleting="TreeList_DataItemDeleting"
            CustomizeEditModel="TreeList_CustomizeEditModel">
    <Columns>
        <DxTreeListCommandColumn>
            <HeaderTemplate>
                <DxButton Click="() => context.TreeList.StartEditNewRowAsync()"
                          Enabled="context.NewEnabled" Text="Add" />
            </HeaderTemplate>
            <CellDisplayTemplate>
                @{
                    <DxButton Click="() => context.TreeList.StartEditRowAsync(context.VisibleIndex)"
                              Text="Edit" Enabled="context.EditEnabled" />
                    <DxButton Click="() => context.TreeList.StartEditNewRowAsync(context.VisibleIndex)"
                              Text="Add" Enabled="context.NewEnabled" />
                    <DxButton Click="() => context.TreeList.ShowRowDeleteConfirmation(context.VisibleIndex)"
                              Text="Delete" Enabled="context.DeleteEnabled" />
                }
            </CellDisplayTemplate>
        </DxTreeListCommandColumn>
        <DxTreeListDataColumn FieldName="Name" Caption="Task" />
        <DxTreeListDataColumn FieldName="EmployeeName" />
        <DxTreeListDataColumn FieldName="StartDate" />
        <DxTreeListDataColumn FieldName="DueDate" />
    </Columns>
</DxTreeList>

@code {
    object TreeListData { get; set; }

    protected override void OnInitialized() {
        var tasks = EmployeeTaskDataProvider.GenerateLargeData().AsQueryable();
        Data = new GridDevExtremeDataSource<EmployeeTask>(tasks);
    }

    void TreeList_CustomizeEditModel(TreeListCustomizeEditModelEventArgs e) {
        // Initialize edit model here
    }

    async Task TreeList_EditModelSaving(TreeListEditModelSavingEventArgs e) {
        // Save changes here
    }

    async Task TreeList_DataItemDeleting(TreeListDataItemDeletingEventArgs e) {
        // Delete items here
    }
}

For more information on how to enable data editing, refer to the following topic: Editing and Validation in Blazor TreeList.

See Also