TreeListHeaderCommandContext Class
Contains contextual information for a TreeList header context menu.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v25.2.dll
NuGet Package: DevExpress.Blazor
Declaration
public class TreeListHeaderCommandContext :
GridHeaderCommandContextBase,
ITreeListCommandContext,
ICommandContextBase
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.
| Target Element | Context Type | Contextual information |
|---|---|---|
| Any | ITreeListCommandContext | TreeList |
| Data Row | TreeListDataRowCommandContext | TreeList, Column, DataItem, RowVisibleIndex |
| Footer | TreeListFooterCommandContext | TreeList, Column, SummaryItems |
| Header | TreeListHeaderCommandContext |
TreeList, Column |
Example
The following code snippet customizes commands available in the header context menu:
@inject EmployeeTaskService EmployeeTaskService
<DxTreeList Data="TreeListData"
KeyFieldName="Id"
ParentKeyFieldName="ParentId"
ContextMenus="TreeListContextMenus.Header"
CustomizeContextMenu="CustomizeContextMenu">
<Columns>
<DxTreeListSelectionColumn Width="80px" />
<DxTreeListDataColumn FieldName="Name" Caption="Task" ShowInColumnChooser="false"/>
<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 TreeListHeaderCommandContext headerContext) {
// Customizes context menu commands for the Task column header
if (headerContext.Column is ITreeListDataColumn dataColumn && dataColumn.Caption == "Task") {
args.Items.Remove(TreeListContextMenuDefaultItemNames.HideColumn);
}
// Customizes context menu commands for the selection column header
if (headerContext.Column is ITreeListSelectionColumn selectionColumn) {
var isFixed = selectionColumn.FixedPosition != TreeListColumnFixedPosition.None;
string itemText = isFixed ? "Unfix Column" : "Fix Column to the Left";
var newValue = isFixed ? TreeListColumnFixedPosition.None : TreeListColumnFixedPosition.Left;
args.Items.AddCustomItem(itemText, () => {
headerContext.TreeList.BeginUpdate();
headerContext.Column.FixedPosition = newValue;
headerContext.TreeList.EndUpdate();
});
}
}
}
}
Inheritance
Object
DevExpress.Blazor.Grid.Internal.Base.ContextMenu.GridCommandContextBase
DevExpress.Blazor.Grid.Internal.Base.ContextMenu.GridHeaderCommandContextBase
TreeListHeaderCommandContext
See Also