Aggregate function - Sum children collection

6 posts, 0 answers
  1. Abdulrahman Omran
    Abdulrahman Omran avatar
    15 posts
    Member since:
    Jan 2011

    Posted 20 Jul 2011 Link to this post

    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
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 21 Jul 2011 Link to this post

    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!

  3. DevCraft banner
  4. Abdulrahman Omran
    Abdulrahman Omran avatar
    15 posts
    Member since:
    Jan 2011

    Posted 21 Jul 2011 Link to this post

    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
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 22 Jul 2011 Link to this post

    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!

  6. Ievgen
    Ievgen avatar
    7 posts
    Member since:
    Jan 2011

    Posted 13 Nov 2012 Link to this post

    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.
  7. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 14 Nov 2012 Link to this post

    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.

Back to Top
DevCraft banner