wpf-118490-controls-and-libraries-data-grid-data-summaries-node-summary.md
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.
View Example: Show Node Summaries in TreeListView
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 ColumnBase.Binding properties to populate columns with data, their ColumnBase.FieldName property values have the following format: RowData.Row.{Your binding path}.
Refer to the following help topic for more information: How the GridControl Identifies Columns.
To obtain a node summary value displayed within a particular node use the TreeListView.GetNodeSummaryValue method.
The TreeListView calculates summaries in the following way.
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.
To show node footers, use the view’s TreeListView.ShowNodeFooters property.
The table below lists the API that allows you to change the node summary appearance.
|
Element
|
Affected Properties
| | --- | --- | |
Node Footer Row
|
TreeListView.NodeFooterRowStyle
TreeListView.NodeFooterRowTemplate
TreeListView.NodeFooterRowTemplateSelector
| |
Node Footer Summary
|
TreeListView.NodeFooterSummaryContentStyle
TreeListSummaryItem.NodeFooterSummaryElementStyle
TreeListView.NodeFooterSummaryElementStyle
| |
Node Footer Summary Item
|
TreeListView.NodeFooterSummaryItemTemplate
TreeListView.NodeFooterSummaryItemTemplateSelector
|
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>
See Also