ASPxTreeList.CustomSummaryCalculate Event
Enables you to calculate summary values manually.
Namespace: DevExpress.Web.ASPxTreeList
Assembly: DevExpress.Web.ASPxTreeList.v24.2.dll
Declaration
Event Data
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. |
Remarks
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.
Example
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;
}
}