aspnet-devexpress-dot-web-dot-aspxtreelist-dot-aspxtreelist-196c54e6.md
Enables you to calculate summary values manually.
Namespace : DevExpress.Web.ASPxTreeList
Assembly : DevExpress.Web.ASPxTreeList.v25.2.dll
NuGet Package : DevExpress.Web
public event TreeListCustomSummaryEventHandler CustomSummaryCalculate
Public Event CustomSummaryCalculate As TreeListCustomSummaryEventHandler
The CustomSummaryCalculate event's data class is TreeListCustomSummaryEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Node | Gets the node currently being processed. Inherited from TreeListNodeEventArgs. |
| SummaryItem | Gets a summary item whose value is being calculated. |
| SummaryProcess | Gets the current calculation stage. |
| Value | Gets or sets the summary value. |
Total summaries and group summaries provide five predefined aggregate functions. These functions allow you to calculate the number of nodes, the maximum and minimum values, the sum and the average value. If you need to calculate a summary value using an aggregate function not included in the predefined set, set the summary item’s TreeListSummaryItem.SummaryType property to SummaryItemType.Custom and handle the CustomSummaryCalculate event.
The CustomSummaryCalculate event fires for each node displayed within the ASPxTreeList. Additionally, the event is raised before and after processing nodes. This can be used to perform any initialization and finalization.
For detailed information and examples, see Custom Aggregate Functions.
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
See Also