Skip to main content
All docs
V25.1
  • DevExpress v25.1 Update — Your Feedback Matters

    Our What's New in v25.1 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

    DxTreeListCommandColumn Class

    A command column.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.1.dll

    NuGet Package: DevExpress.Blazor

    #Declaration

    #Remarks

    The command column displays predefined New, Edit, and Delete buttons for data rows in display mode. In EditRow and EditCell edit modes, this column displays Save and Cancel buttons for the edited row. In the filter row, the column displays the Clear button.

    Blazor TreeList Command Column

    #Add a Command Column

    Declare a DxTreeListCommandColumn object in the Columns template. Use the Width property to specify the column width. The FixedPosition property allows you to freeze the column and keep it visible on the screen while users scroll the TreeList horizontally.

    To hide unnecessary command buttons, disable the following properties:

    The following code snippet hides Delete buttons:

    <DxTreeList Data="TreeListData" KeyFieldName="Id" ParentKeyFieldName="ParentId">
        <Columns>
            <DxTreeListCommandColumn Width="150px" DeleteButtonVisible="false" />
            @*...*@
        </Columns>
    </DxTreeList>
    

    #Edit Data

    When a user clicks a New or Edit button, the TreeList starts editing the corresponding row. Handle the EditStart event to create a custom response to a start edit action. To create a custom response to the Cancel button click, handle the EditCanceling event.

    The EditModelSaving event fires when a user clicks the Save button and validation is passed. Handle this event to make final data changes, check access permissions, post changes to the underlying data source, and reload TreeList data.

    When the user clicks a Delete button, the delete confirmation dialog appears. The DataItemDeleting event fires when the user confirms the delete operation. Handle this event to check user access permissions, delete a data item from the underlying data source, and reload TreeList data.

    The following example implements data editing in the TreeList component:

    Blazor TreeList Inline Edit Row

    @inject EmployeeTaskService EmployeeTaskService
    
    <DxTreeList Data="TreeListData"
                KeyFieldName="Id"
                ParentKeyFieldName="ParentId"
                EditModelSaving="TreeList_EditModelSaving"
                DataItemDeleting="TreeList_DataItemDeleting"
                CustomizeEditModel="TreeList_CustomizeEditModel">
        <Columns>
            <DxTreeListCommandColumn />
            <DxTreeListDataColumn FieldName="Name" Caption="Task" />
            <DxTreeListDataColumn FieldName="EmployeeName" />
            <DxTreeListDataColumn FieldName="StartDate" />
            <DxTreeListDataColumn FieldName="DueDate" />
        </Columns>
    </DxTreeList>
    
    @code {
        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;
                newTask.Name = "New task";
                newTask.StartDate = DateTime.Today;
                newTask.DueDate = DateTime.Today.AddDays(7);
                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);
        }
    }
    

    Read Tutorial: Edit Data Run Demo: Edit Data

    You can define the column’s CellDisplayTemplate, CellEditTemplate, and HeaderTemplate to implement custom command elements.

    #Filter Data

    Enable the ShowFilterRow option to activate the filter row. This row displays in-place text editors for all data columns. When a user types into an editor, the TreeList creates a filter condition based on the editor value and applies this condition to the corresponding column.

    Users can click the Clear button in the command column to reset the entire filter.

    Blazor TreeList Filter Row Command Column

    @inject EmployeeTaskService EmployeeTaskService
    
    <DxTreeList Data="TreeListData" KeyFieldName="Id" ParentKeyFieldName="ParentId" ShowFilterRow="true">
        <Columns>
            <DxTreeListCommandColumn />
            <DxTreeListDataColumn FieldName="Name"
                                  Caption="Task"
                                  FilterRowValue='"Sales"'
                                  FilterRowOperatorType="TreeListFilterRowOperatorType.Contains" />
            <DxTreeListDataColumn FieldName="EmployeeName"  />
            <DxTreeListDataColumn FieldName="StartDate" />
            <DxTreeListDataColumn FieldName="DueDate" />
        </Columns>
    </DxTreeList>
    
    @code {
        List<EmployeeTask> TreeListData { get; set; }
    
        protected override void OnInitialized() {
            TreeListData = EmployeeTaskService.GenerateData();
        }
    }
    

    Read Tutorial: Filter Row

    You can define the FilterRowCellTemplate to display custom content in the command column’s filter row cell.

    #Inheritance

    Object
    ComponentBase
    DevExpress.Blazor.Internal.BranchedRenderComponent
    DevExpress.Blazor.Internal.ParameterTrackerSettingsComponent
    DevExpress.Blazor.Internal.GridColumnBase
    DxTreeListColumn
    DxTreeListCommandColumn
    See Also