aspnet-4012-components-tree-list-examples-how-to-calculate-custom-summaries.md
This example shows how to implement a custom summary calculation.
Create a summary item within the ASPxTreeList.Summary collection and customize its settings as shown below:
The ASPxTreeList.CustomSummaryCalculate event is handled to sum the budgets of selected departments. Finally, set the TreeListSettingsBehavior.ProcessSelectionChangedOnServer option to true.
The image below shows the result:
using DevExpress.Data;
protected void ASPxTreeList2_CustomSummaryCalculate(object sender,
TreeListCustomSummaryEventArgs e) {
switch (e.SummaryProcess) {
case CustomSummaryProcess.Start:
e.Value = (int)0;
break;
case CustomSummaryProcess.Calculate:
if (e.Node.Selected)
e.Value = (int)e.Value + (int)e.Node["Budget"];
break;
case CustomSummaryProcess.Finalize:
break;
}
}
Imports DevExpress.Data
Protected Sub ASPxTreeList2_CustomSummaryCalculate(ByVal sender As Object,_
ByVal e As TreeListCustomSummaryEventArgs)
Select Case e.SummaryProcess
Case CustomSummaryProcess.Start
e.Value = CInt(Fix(0))
Case CustomSummaryProcess.Calculate
If e.Node.Selected Then
e.Value = CInt(Fix(e.Value)) + CInt(Fix(e.Node("Budget")))
End If
Case CustomSummaryProcess.Finalize
End Select
End Sub