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.

WPF_TreeList_NodeSummary

This topic consists of the following sections.

Displaying Node Summaries

To create a node summary item at design time, use the NodeSummary Collection Editor.

WPF_TreeList_NodeSummaryEditor

<dxg:TreeListView AutoExpandAllNodes="True" ShowNodeFooters="True" ShowTotalSummary="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);

Obtaining 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.

group_footers

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

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>