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

    Returns a column that contains the target cell.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.2.dll

    NuGet Package: DevExpress.Blazor

    Declaration

    public ITreeListColumn Column { get; }

    Property Value

    Type Description
    ITreeListColumn

    A TreeList column.

    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 Column property to access a column containing the target cell.

    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();
                });
            }
        }
    }
    
    See Also