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

Custom Aggregate Function across two columns

3 Answers 234 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Edwin
Top achievements
Rank 1
Edwin asked on 13 Dec 2012, 11:35 PM
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>

 

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 14 Dec 2012, 07:50 AM
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.

0
Andy
Top achievements
Rank 1
answered on 05 Feb 2013, 07:35 PM

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.

0
Andy
Top achievements
Rank 1
answered on 06 Feb 2013, 07:23 PM
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).
Tags
GridView
Asked by
Edwin
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Andy
Top achievements
Rank 1
Share this question
or