Skip to main content

Custom Summaries

  • 2 minutes to read

Custom Summaries

The Tree List provides a TreeList.GetCustomSummaryValue event which enables you to implement custom aggregate functions. For instance, you may want to calculate the number of nodes which have column values below a certain level. Another example is calculating a discount from the maximum value. In such cases, you should write a GetCustomSummaryValue event handler.

If you want to calculate the footer summary or group summary in a custom way, set the TreeListColumn.SummaryFooter or TreeListColumn.RowFooterSummary property to SummaryItemType.Custom. Otherwise the TreeList.GetCustomSummaryValue event will not fire.

The event’s parameter provides the following properties that can be used to calculate the resulting summary value.


The following example calculates the number of records for which the “Budget” column’s value exceeds 500,000. The setCustomSummary method sets the custom summary type for the Budget column. The TreeList.GetCustomSummaryValue event handler implements the calculation logic.

The image below shows the result.


private void setCustomSummary() {
   treeList1.OptionsView.ShowRowFooterSummary = true;
   treeList1.Columns["Budget"].RowFooterSummary = SummaryItemType.Custom;
   treeList1.Columns["Budget"].RowFooterSummaryStrFormat = "{0} nodes exceed limit";

private void treeList1_GetCustomSummaryValue(object sender, DevExpress.XtraTreeList.GetCustomSummaryValueEventArgs e) {
   if(e.Column.FieldName == "Budget") {
      IEnumerator en = e.Nodes.GetEnumerator();
      int exceedingLimitNodes = 0;
      while(en.MoveNext()) {
         TreeListNode node = (TreeListNode)en.Current;
         decimal budget = (decimal)node.GetValue(e.Column);
         if(budget > 500000) {
            exceedingLimitNodes ++;
      e.CustomValue = exceedingLimitNodes;