TreeListFooterCommandContext.SummaryItems Property
Returns total summaries contained in the target cell.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v25.2.dll
NuGet Package: DevExpress.Blazor
Declaration
public IReadOnlyList<ITreeListSummaryItem> SummaryItems { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<ITreeListSummaryItem> | A total summary collection. |
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 SummaryItems property to access total summaries contained in the target cell.
Example
The following example adds context commands that display/hide total summaries:

@inject EmployeeTaskService EmployeeTaskService
<DxTreeList Data="TreeListData"
PageSize="5"
KeyFieldName="Id"
ParentKeyFieldName="ParentId"
FooterDisplayMode="TreeListFooterDisplayMode.Always"
ContextMenus="TreeListContextMenus.Footer"
CustomizeContextMenu="CustomizeContextMenu">
<Columns>
<DxTreeListSelectionColumn Width="80px" />
<DxTreeListDataColumn FieldName="Name" Caption="Task" ShowInColumnChooser="false" />
<DxTreeListDataColumn FieldName="EmployeeName" />
<DxTreeListDataColumn FieldName="StartDate" />
<DxTreeListDataColumn FieldName="DueDate" />
</Columns>
<TotalSummary>
@foreach (var item in SummaryItems) {
<DxTreeListSummaryItem FieldName="@item.FieldName"
SummaryType="item.Type"
ValueDisplayFormat="@item.DisplayFormat"
@key="item" />
}
</TotalSummary>
</DxTreeList>
@code {
List<EmployeeTask> TreeListData { get; set; }
IList<SummaryItem> SummaryItems { get; set; }
static readonly TreeListSummaryItemType[] SummaryTypes = Enum.GetValues<TreeListSummaryItemType>()
.Where(s => s != TreeListSummaryItemType.None && s != TreeListSummaryItemType.Custom && s != TreeListSummaryItemType.Sum)
.ToArray();
bool IsStringColumn(string fieldName) => new[] { "Name", "EmployeeName" }.Contains(fieldName);
record SummaryItem(string FieldName, TreeListSummaryItemType Type) {
public string DisplayFormat { get; init; }
}
protected override void OnInitialized() {
TreeListData = EmployeeTaskService.GenerateData();
SummaryItems = new List<SummaryItem>([
new SummaryItem("DueDate", TreeListSummaryItemType.Count),
]);
}
void CustomizeContextMenu(TreeListCustomizeContextMenuEventArgs args) {
ITreeListColumn column = null;
IReadOnlyList<ITreeListSummaryItem> contextSummaryItems = null;
IList<SummaryItem> summaryItemsCollection = null;
if (args.Context is TreeListFooterCommandContext footerCommandContext) {
column = footerCommandContext.Column;
contextSummaryItems = footerCommandContext.SummaryItems;
summaryItemsCollection = SummaryItems;
}
if (column != null && column is ITreeListDataColumn dataColumn) {
foreach (var summaryType in SummaryTypes) {
var fieldName = dataColumn.FieldName;
if (IsStringColumn(fieldName) && summaryType != TreeListSummaryItemType.Count)
continue;
var existingItem = contextSummaryItems.FirstOrDefault(i => i.FieldName == fieldName && i.SummaryType == summaryType);
var menuItem = args.Items.AddCustomItem(summaryType.ToString(), () => OnSummaryCommand(dataColumn, summaryType, summaryItemsCollection));
}
}
}
void OnSummaryCommand(ITreeListDataColumn dataColumn, TreeListSummaryItemType summaryType, IList<SummaryItem> summaryItemsCollection) {
var fieldName = dataColumn.FieldName;
var existingItem = summaryItemsCollection.FirstOrDefault(i => i.FieldName == fieldName && i.Type == summaryType);
if (existingItem != null)
summaryItemsCollection.Remove(existingItem);
else
summaryItemsCollection.Add(new SummaryItem(fieldName, summaryType) {
DisplayFormat = summaryType == TreeListSummaryItemType.Count ? null : dataColumn.DisplayFormat
});
StateHasChanged();
}
}