Skip to main content
All docs
V24.2

DxTreeList.ShowRowDeleteConfirmation(Int32) Method

Displays the delete confirmation dialog for the specified row. If a user confirms the operation, the method raises the DataItemDeleting event.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

Declaration

public void ShowRowDeleteConfirmation(
    int visibleIndex
)

Parameters

Name Type Description
visibleIndex Int32

The row’s visible index.

Remarks

This method allows you to implement your custom Delete button inside or outside the TreeList.

Handle a button’s click event and call the ShowRowDeleteConfirmation method to display the delete confirmation dialog for the specified row. The DataItemDeleting event fires when a user confirms the delete operation. Handle this event to check user access permissions and delete the data item from the underlying data source.

Note

When the TreeList is bound to the GridDevExtremeDataSource or loads data on demand, call the WaitForRemoteSourceRowLoadAsync(Int32) method before you execute the ShowRowDeleteConfirmation method to ensure that the specified data row is loaded.

The TreeList also includes the following edit-related methods:

StartEditNewRowAsync
Starts editing a new row.
StartEditRowAsync
Start editing the specified row.
CancelEditAsync
Cancels row editing and discards changes.
SaveChangesAsync
Saves changes.

The following code snippet displays icons instead of default command buttons:

@inject EmployeeTaskService EmployeeTaskService

<DxTreeList @ref="MyTreeList"
            Data="TreeListData"
            KeyFieldName="Id"
            ParentKeyFieldName="ParentId"
            EditMode="TreeListEditMode.EditForm"
            EditModelSaving="TreeList_EditModelSaving"
            DataItemDeleting="TreeList_DataItemDeleting"
            CustomizeEditModel="TreeList_CustomizeEditModel">
    <Columns>
        <DxTreeListCommandColumn Width="90px">
            <HeaderTemplate>
                <a class="oi oi-plus" @onclick="@(() => MyTreeList.StartEditNewRowAsync())" style="text-decoration: none;" href="javascript:void(0);"></a>
            </HeaderTemplate>
            <CellDisplayTemplate>
                <a class="oi oi-pencil" @onclick="@(() => MyTreeList.StartEditRowAsync(context.VisibleIndex))" style="text-decoration: none;" href="javascript:void(0);"></a>
                <a class="oi oi-plus" @onclick="@(() => MyTreeList.StartEditNewRowAsync(context.VisibleIndex))" style="text-decoration: none;" href="javascript:void(0);"></a>
                <a class="oi oi-x" @onclick="@(() => MyTreeList.ShowRowDeleteConfirmation(context.VisibleIndex))" style="text-decoration: none;" href="javascript:void(0);"></a>
            </CellDisplayTemplate>
        </DxTreeListCommandColumn>
        <DxTreeListDataColumn FieldName="Name" Caption="Task" />
        <DxTreeListDataColumn FieldName="EmployeeName" />
        <DxTreeListDataColumn FieldName="StartDate" />
        <DxTreeListDataColumn FieldName="DueDate" />
    </Columns>
    <EditFormTemplate Context="EditFormContext">
        <DxFormLayout CssClass="w-100">
            <DxFormLayoutItem Caption="Task:" ColSpanMd="6">
                @EditFormContext.GetEditor("Name")
            </DxFormLayoutItem>
            <DxFormLayoutItem Caption="Employee Name:" ColSpanMd="6">
                @EditFormContext.GetEditor("EmployeeName")
            </DxFormLayoutItem>
            <DxFormLayoutItem Caption="Start Date:" ColSpanMd="6">
                @EditFormContext.GetEditor("StartDate")
            </DxFormLayoutItem>
            <DxFormLayoutItem Caption="Due Date:" ColSpanMd="6">
                @EditFormContext.GetEditor("DueDate")
            </DxFormLayoutItem>
        </DxFormLayout>
    </EditFormTemplate>
</DxTreeList>

@code {
    ITreeList MyTreeList { get; set; }
    List<EmployeeTask> TreeListData { get; set; }

    protected override void OnInitialized() {
        TreeListData = EmployeeTaskService.GenerateData();
    }
    void TreeList_CustomizeEditModel(TreeListCustomizeEditModelEventArgs e) {
        if (e.IsNew) {
            var newTask = (EmployeeTask)e.EditModel;
            newTask.Id = TreeListData.Max(x => x.Id) + 1;
            if (e.ParentDataItem != null) {
                newTask.ParentId = ((EmployeeTask)e.ParentDataItem).Id;
            }
        }
    }
    async Task TreeList_EditModelSaving(TreeListEditModelSavingEventArgs e) {
        if (e.IsNew)
            TreeListData.Add((EmployeeTask)e.EditModel);
        else
            e.CopyChangesToDataItem();
    }
    async Task TreeList_DataItemDeleting(TreeListDataItemDeletingEventArgs e) {
        TreeListData.Remove((EmployeeTask)e.DataItem);
    }
}

Blazor TreeList Editing Custom Command Buttons

Refer to the following topic for more information: Editing and Validation in Blazor TreeList.

See Also