This is a migrated thread and some comments may be shown as answers.

Aggregate function - Sum children collection

5 Answers 132 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Abdulrahman Omran
Top achievements
Rank 1
Abdulrahman Omran asked on 21 Jul 2011, 03:10 AM
Hi,

I'm using the RadTreeViewList control and i was to display aggregated values at the footer.
My Data has infinite number of levels. My items source is an observable collection of Tasks. Where a task has collection called Children tasks.

I have added aggregate functions in some of the columns like this:
 
<telerik:GridViewDataColumn IsReadOnly="True" DataMemberBinding="{Binding BudgetHours, Mode=OneWay}" Header="Budget Hours" >
                   <telerik:GridViewDataColumn.AggregateFunctions>
                       <telerik:SumFunction Caption="Total: "/>
                   </telerik:GridViewDataColumn.AggregateFunctions>
               </telerik:GridViewDataColumn>



But the problem with this is that it will sum the values at the root level and not add from the children tasks.
Is there an elegant soultion for this ?


Thanks,
Abdul

5 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 21 Jul 2011, 07:21 AM
Hi Abdulrahman Omran,

For the time being the aggregates are applied only at the root level. However, we have logged it as a feature request into our Public Issue Tracking System. I would encourage you to vote for it as the higher its rating is, the more important and with higher priority it gets. 
 

Best wishes,
Maya
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Abdulrahman Omran
Top achievements
Rank 1
answered on 22 Jul 2011, 12:21 AM
Hi Maya,

thank you for your quick reply. I have already voted for the issue in PITS.

I was thinking of implementing a custom filter that will recursively sum values from child collections. However since i have different columns to sum i will have to write a separate fuction for each. Is there a way to pass the name of the column to the aggregate function so i can use Reflection to sum the values from the named property ? .
i.e. im looking for something like a converter parameter that will pass the property name to the custom aggegate function.


Thanks,
Abdul
0
Maya
Telerik team
answered on 22 Jul 2011, 10:39 AM
Hi Abdulrahman Omran,

Generally, you may find the name of the column using its UniqueName property. Another possible approach would be to get the name of the underlying property:

string propertyName = ((GridViewDataColumn)this.myGrid.Columns[1]).DataMemberBinding.Path.Path;
 

All the best,
Maya
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Ievgen
Top achievements
Rank 1
answered on 13 Nov 2012, 03:02 PM
Hi,

I need the opposite - to show totals for top-level items only. Is there now a way to configure TreeListView (or aggregate function) to do this?

Thanks.
0
Maya
Telerik team
answered on 14 Nov 2012, 07:28 AM
Hi Ievgen,

Such scenario is currently not supported out-of-the-box. You need to create custom aggregate function that will calculate only the root items. Check out this and this demos for a reference.

 

Greetings,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
TreeListView
Asked by
Abdulrahman Omran
Top achievements
Rank 1
Answers by
Maya
Telerik team
Abdulrahman Omran
Top achievements
Rank 1
Ievgen
Top achievements
Rank 1
Share this question
or