Custom Aggregate Function across two columns

4 posts, 0 answers
  1. Edwin
    Edwin avatar
    14 posts
    Member since:
    Mar 2012

    Posted 13 Dec 2012 Link to this post

    Hello,

    I have a gridview with the set of columns shown below.  The first two columns have AggregateFunctions (sum).  I have a third column which should be the the result of dividing VacantSpaceRentableArea by TotalArea. I need this to be inside a custom aggregate function as the totals need to be recalculated as users group data by different columns. 

    I have seen the examples of custom aggregate functions but all the examples I have seen refer only one column.  Is there any way to implement a custom aggregate function that references more than one column?

    Thanks.

    Edwin


    <

     

     

    telerik:GridViewDataColumn Header="Total Area" DataMemberBinding="{Binding TotalArea}" IsReadOnly="True"  DataFormatString="N0">

     

     

     

     

        <telerik:GridViewDataColumn.AggregateFunctions>

     

     

     

     

            <telerik:SumFunction Caption="Total Area: "/>

     

     

     

     

        </telerik:GridViewDataColumn.AggregateFunctions>

     

     

     

     

    </telerik:GridViewDataColumn>

     

     

     

     

    <telerik:GridViewDataColumn Header="Vac. Space Rentable Area" DataMemberBinding="{Binding VacantSpaceRentableArea}" IsReadOnly="True" DataFormatString="N0">

     

     

     

     

        <telerik:GridViewDataColumn.AggregateFunctions>

     

     

     

     

            <telerik:SumFunction Caption="Total Rentable Area: "/>

     

     

     

     

        </telerik:GridViewDataColumn.AggregateFunctions>

     

     

     

     

    </telerik:GridViewDataColumn>

     

     

     

     


    <
    telerik:GridViewDataColumn Header="Vac. % Based on Rentable Area" DataMemberBinding="{Binding VacancyPctOfRentableArea}" IsReadOnly="True" DataFormatString="P2">

     

     

     

     

    <!-- Need custom aggregate function here that will calculate VacantSpaceRentableArea / TotalArea -->

     

     

     

     

    </telerik:GridViewDataColumn>

     

  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 14 Dec 2012 Link to this post

    Hello,

     Actually the aggregation in this demo is a bit more complex. 

    All the best,
    Vlad
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Andy
    Andy avatar
    2 posts
    Member since:
    Jan 2013

    Posted 05 Feb 2013 Link to this post

    I find the demos to not be as useful as I would like, partly because the parts available in the code section do not appear to be complete, and partly because they lack any kind of overview of what is going on.

     

    So, can you do me a favor and sketch things out for me – Let’s assume I have class with two properties, Amount and Rate and I want to have a weighted rate value as the Aggregate value of my Rate column.  A weighted rate is calculated as sum(Rate*Amount)/sum(Amount).  What would my Accumulator class look like and what would my GridViewDataColumn look like?  (If you want to keep it simple, just show the outline of the Accumulator class and I can fill in the pieces.)

    - what would be really useful would be some documentation explaining how everything fits together.

  4. Andy
    Andy avatar
    2 posts
    Member since:
    Jan 2013

    Posted 06 Feb 2013 Link to this post

    Figured it out, kinda, close enough.  (I still think the examples would be better if figuring it out didn't rely on my personal pattern matching of things to figure out how things are related).
Back to Top