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

how to do this aggregate?

3 Answers 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Henry
Top achievements
Rank 1
Henry asked on 07 Apr 2012, 07:07 AM
three columns in the grid, I want to the aggregate value in the third column = sum(first column) / sum(second column) -1, and show it in percentage. I guess this has to be done in the code behide, how to wire that?

Thanks.

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 07 Apr 2012, 07:52 AM
Hello Henry,

Please check below code snippet.
<telerik:GridCalculatedColumn HeaderText="Total"  DataType="System.Double"
                       DataFields="Column1, Column2"  Expression="({0}/{1})-1" 
                       Aggregate="Avg" />

Note : if you want to sum then use Aggregate="Sum" in above code.

Thanks,
Jayesh Goyani
0
Henry
Top achievements
Rank 1
answered on 07 Apr 2012, 04:13 PM
Jayesh,

1).somewho I can't add the calculated column in the grid, whenever I add it, the page failed to load and show exception on another column(which works fine without calculated column. the error is below, where 'XXXX' is the class that bind to the grid.

Unable to cast object of type 'DynamicClass1' to type 'XXXX'.


2). to do the custom aggregate in the code behind, I found this http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/aggregates/defaultcs.aspx, the question is that in the example, the result is assigned to "e.Result", what if there two more than one custom aggregate? how do we know which column is the e.Result point to?

Thanks.


0
Henry
Top achievements
Rank 1
answered on 08 Apr 2012, 05:13 AM
still not sure about what happen on 1.

for 2, I've figure it out. 

thanks.
Tags
Grid
Asked by
Henry
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Henry
Top achievements
Rank 1
Share this question
or