Skip to main content
All docs
V25.2
  • TreeListCustomizeContextMenuEventArgs.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.

    DevExpress Blazor TreeList - Context Menus

    Run Demo: Context Menu

    Handle the CustomizeContextMenu event to modify the menu item collection. Use the TreeList event argument to access the TreeList and its extensive API.

    Example

    The following example adds custom Show Footer/Hide Footer commands to all context menus:

    @inject EmployeeTaskService EmployeeTaskService
    
    <DxTreeList Data="TreeListData"
                KeyFieldName="Id"
                ParentKeyFieldName="ParentId"
                ContextMenus="TreeListContextMenus.All"
                CustomizeContextMenu="CustomizeContextMenu">
        <Columns>
            <DxTreeListDataColumn FieldName="Name" Caption="Task" />
            <DxTreeListDataColumn FieldName="EmployeeName" />
            <DxTreeListDataColumn FieldName="StartDate" />
            <DxTreeListDataColumn FieldName="DueDate" />
        </Columns>
        <TotalSummary>
            <DxTreeListSummaryItem SummaryType="TreeListSummaryItemType.Count" FieldName="DueDate" />
        </TotalSummary>
    </DxTreeList>
    
    @code {
        List<EmployeeTask> TreeListData { get; set; }
    
        protected override void OnInitialized() {
            TreeListData = EmployeeTaskService.GenerateData();
        }
        void CustomizeContextMenu(TreeListCustomizeContextMenuEventArgs args) {
            var isFooterVisible = args.TreeList.FooterDisplayMode != TreeListFooterDisplayMode.Never;
            string footerItemText = isFooterVisible ? "Hide Footer" : "Show Footer";
            var newState = isFooterVisible ? TreeListFooterDisplayMode.Never : TreeListFooterDisplayMode.Always;
            args.Items.AddCustomItem(0, footerItemText, () => {
                args.TreeList.BeginUpdate();
                args.TreeList.FooterDisplayMode = newState;
                args.TreeList.EndUpdate();
            });
        }
    }
    
    See Also