Skip to main content
All docs
V25.2
  • TreeListDataRowCommandContext.TreeList Property

    Returns the TreeList object.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.2.dll

    NuGet Package: DevExpress.Blazor

    Declaration

    public ITreeList TreeList { get; }

    Property Value

    Type Description
    ITreeList

    The TreeList object.

    Remarks

    The DevExpress Blazor TreeList allows you to display context menus with predefined and custom commands. Use the ContextMenus property to activate context menus for specific TreeList elements. Handle the CustomizeContextMenu event to modify the menu item collection. Use the Context event argument to identify the target TreeList element and obtain contextual information.

    When the target element is a data row cell, the Context property returns a TreeListDataRowCommandContext object. Use the object’s TreeList property to access the TreeList and its extensive API.

    Example

    The following code snippet adds custom commands to the row context menu associated with selection cells:

    @inject EmployeeTaskService EmployeeTaskService
    
    <DxTreeList Data="TreeListData"
                KeyFieldName="Id"
                ParentKeyFieldName="ParentId"
                ContextMenus="TreeListContextMenus.DataRow"
                CustomizeContextMenu="CustomizeContextMenu">
        <Columns>
            <DxTreeListSelectionColumn Width="80px" />
            <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 CustomizeContextMenu(TreeListCustomizeContextMenuEventArgs args) {
            if (args.Context is TreeListDataRowCommandContext rowContext
                                && rowContext.Column is ITreeListSelectionColumn) {
                args.Items.AddCustomItem("Select All", async () => {
                    args.TreeList.BeginUpdate();
                    await args.TreeList.SelectAllAsync();
                    args.TreeList.EndUpdate();
                });
                args.Items.AddCustomItem("Deselect All", async () => {
                    args.TreeList.BeginUpdate();
                    await args.TreeList.DeselectAllAsync();
                    args.TreeList.EndUpdate();
                });
                args.Items.AddCustomItem("Select All on Page", () => {
                    args.TreeList.BeginUpdate();
                    args.TreeList.SelectAllOnPage();
                    args.TreeList.EndUpdate();
                });
                args.Items.AddCustomItem("Deselect All on Page", () => {
                    args.TreeList.BeginUpdate();
                    args.TreeList.DeselectAllOnPage();
                    args.TreeList.EndUpdate();
                });
            }
        }
    }
    

    Implements

    See Also