Node Summary
- 2 minutes to read
A node summary represents a value of the aggregate function calculated against all child nodes within a parent node. Node summaries are displayed within node footers and stored in the view’s TreeListView.NodeSummary collection.
#Display Node Summaries
To create a node summary item at design time, use the NodeSummary Collection Editor.
<dxg:TreeListView AutoExpandAllNodes="True" ShowNodeFooters="True">
<dxg:TreeListView.NodeSummary>
<dxg:TreeListSummaryItem FieldName="MeanRadiusInKM" SummaryType="Max" />
<dxg:TreeListSummaryItem FieldName="MeanRadiusInKM" SummaryType="Min" />
<dxg:TreeListSummaryItem FieldName="Mass10pow21kg" SummaryType="Max" />
<dxg:TreeListSummaryItem FieldName="Mass10pow21kg" SummaryType="Min" />
</dxg:TreeListView.NodeSummary>
</dxg:TreeListView>
To display node summaries in code, create a new instance of the TreeListSummaryItem class, specify its properties, and add it to the TreeListView.NodeSummary collection.
DevExpress.Xpf.Grid.TreeListSummaryItem nodeSummaryItem = new DevExpress.Xpf.Grid.TreeListSummaryItem();
nodeSummaryItem.FieldName = "MeanRadiusInKM";
nodeSummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Max;
view.NodeSummary.Add(nodeSummaryItem);
Use the AddRange method to add multiple summary items.
Note
If you use Column
Refer to the following help topic for more information: How the Grid
#Obtain Summary Values
To obtain a node summary value displayed within a particular node use the TreeListView.GetNodeSummaryValue method.
#Recursive Summary Calculation
The TreeListView calculates summaries in the following way.
- Total summaries are calculated recursively, and thus all the column values affect the summary value.
- Node summaries are calculated at a single level only, i.e. in non-recursive manner.
To enable or disable recursive summary calculation for a particular summary item, use the TreeListSummarySettings.IsRecursive attached property.
Use the TreeListView.AllowRecursiveNodeSummaryCalculation property to enable or disable the recursive node summary calculation for the entire TreeListView.
#Node Footers
To show node footers, use the view’s TreeListView.ShowNodeFooters property.
#Node Summary Appearance Customization
The table below lists the API that allows you to change the node summary appearance.
Element | Affected Properties |
---|---|
Node Footer Row | Tree |
Node Footer Summary | Tree |
Node Footer Summary Item |
The code sample below demonstrates how to change the style applied to the node summary items.
<dxg:TreeListControl ... >
<dxg:TreeListControl.View>
<dxg:TreeListView ShowNodeFooters="True" ...>
<dxg:TreeListView.NodeSummary>
<dxg:TreeListSummaryItem FieldName="MeanRadius" SummaryType="Max" />
...
</dxg:TreeListView.NodeSummary>
<!-- Changing the style applied to node footer summaries -->
<dxg:TreeListView.NodeFooterSummaryContentStyle>
<Style>
<Setter Property="TextElement.Foreground" Value="Green"/>
</Style>
</dxg:TreeListView.NodeFooterSummaryContentStyle>
</dxg:TreeListView>
</dxg:TreeListControl.View>
</dxg:TreeListControl>