TreeListFooterCommandContext.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 footer cell, the Context property returns a TreeListFooterCommandContext object. Use the object’s TreeList property to access the TreeList and its extensive API.
Example
The following example adds custom Show Filter Panel/Hide Filter Panel commands to the footer context menu:
@inject EmployeeTaskService EmployeeTaskService
<DxTreeList Data="TreeListData"
KeyFieldName="Id"
ParentKeyFieldName="ParentId"
FilterPanelDisplayMode="TreeListFilterPanelDisplayMode.Always"
ContextMenus="TreeListContextMenus.Footer"
CustomizeContextMenu="CustomizeContextMenu">
<Columns>
<DxTreeListSelectionColumn Width="80px" />
<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) {
if (args.Context is TreeListFooterCommandContext footerContext) {
var isFilterPanelVisible = footerContext.TreeList.FilterPanelDisplayMode != TreeListFilterPanelDisplayMode.Never;
string itemText = isFilterPanelVisible ? "Hide Filter Panel" : "Show Filter Panel";
var newState = isFilterPanelVisible ? TreeListFilterPanelDisplayMode.Never : TreeListFilterPanelDisplayMode.Always;
args.Items.AddCustomItem(0, itemText, () => {
footerContext.TreeList.BeginUpdate();
footerContext.TreeList.FilterPanelDisplayMode = newState;
footerContext.TreeList.EndUpdate();
});
}
}
}