Telerik blogs

I want to introduce you another cool feature for the RadTreeList which is available into the new Q1 2011 release of RadControls for ASP.NET AJAX. With the new version the RadTreeList provides functionality for displaying summaries/results from aggregates in the footer item. The type of this footer item is TreeListFooterItem. To enable this functionality merely set the ShowFooter property of the respective RadTreeList instance to true (its default value is false). The TreeListFooterItem is most commonly used to visualize calculations from aggregate functions within the scope of the current level:

Aggregates first look

In order to specify how the aggregates will be evaluated, specify in every RadTreeList column which have the Aggregate property one of the option from the TreeListAggregateFunction enumeration:
  • Sum- Returns the sum of all column values in the source.
  • Min - Returns the min value from the source column.
  • Max - Returns the max value from the source column.
  • Last - Returns the last value from the source column.
  • First - Returns the first value from the source column.
  • Count - Returns the count of source column values.
  • Avg - Returns the average value from the source column values.
  • None - Default value, no aggregate function applied.
Also you could add text to the calculated value by using the FooterText property or format the evaluated aggregate value by FooterAggregateFormatString property:
...
<telerik:TreeListBoundColumn FooterAggregateFormatString="Count: {0}"
HeaderText="LocationName" Aggregate="Count" DataField="LocationName">
</
telerik:TreeListBoundColumn>
<
telerik:TreeListNumericColumn DataField="Population" Aggregate="Sum"
DataType="System.Double" FooterAggregateFormatString="Sum: {0:n}"
HeaderText="Population" DataFormatString="{0:n}">
</
telerik:TreeListNumericColumn>
<
telerik:TreeListNumericColumn DataField="Area" HeaderText="Area"
Aggregate="Sum" DataFormatString="{0:n} km<sup>2</sup>"
DataType="System.Double"
FooterAggregateFormatString="Sum: {0:n} km<sup>2</sup>">
</
telerik:TreeListNumericColumn>
...

Formatting Aggregates

Another important thing is that aggregates for the RadTreeList are calculated over the entire level. If some of the items are on the other page they will be included into the aggregates calculation. Also if the item is collapsed and it has child items the evaluated aggregate will calculate the values of the collapsed child items too.

Aggregates with paging

Aggregates with paging

Additionally you could find an example of RadTreeList aggregates on the following link.

About the Author

Iana Tsolova

is Product Manager at Telerik’s DevTools division. She joined the company back in the beginning of 2008 as a Support Officer and has since occupied various positions at Telerik, including Senior Support Officer, Team Lead at one of the ASP.NET AJAX teams and Technical Support Director. Iana’s main interests are web development, reading articles related to geography, wild nature and latest renewable energy technologies.

Related Posts

Comments

Comments are disabled in preview mode.