Skip to main content
All docs
V24.2

TreeListCommandColumnCellDisplayTemplateContext.DeleteEnabled Property

Returns whether the Delete 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

public bool DeleteEnabled { get; }

Property Value

Type Description
Boolean

true if the delete 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:

@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