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

[Solved] Aggregate on template column

3 Answers 120 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Rajesh SV
Top achievements
Rank 1
Rajesh SV asked on 21 Jan 2012, 07:16 AM
Hi,

I am using telerik mvc grid for showing my order details. In the grid I have a calculated column for showing total price(unit price * qty) for which I am using a template column. I need to show aggregate of this column in footer template. But I couldn't see aggregate option on template columns which is available on bound columns. Is there a way to achieve this?

Thanks in advance.

Rajesh

3 Answers, 1 is accepted

Sort by
0
Behtash Moradi
Top achievements
Rank 1
answered on 24 Feb 2012, 12:10 AM
I came across with a problem  such as you got.
 I think  following trick may work for you as it worked for me.
you need to apply aggregate method first and then call template method.

columns.Bound(x => x.ForecastFee).Aggregate(agg =>
agg.Sum()).Format("{0:C}").FooterTemplate(@<text> Total:
@item.Sum</text>).Template(o => string.Format("<a
id='jobPlanIdForecastCRFees_{0}'     href='javascript:void(0)'
data-keyvalue='{1}' data-keyname='jobPlanId' data-keyvalue2='{2}'
data-keyname2='activityId'>{3}</a>", o.Code, o.ActivityGroupId,
 o.Id, o.ForecastFee.ToString("C"))).Title("Forecast CR/Fees");
hope it solves your issue
Regard
Behtash Moardi
0
Rajesh SV
Top achievements
Rank 1
answered on 27 Feb 2012, 04:49 PM
Thanks Behtash for your reply.

This has solved my problem. However I found another issue with this. I am not able to apply sorting on this column.

Any clue?

Regards,
Rajesh
0
Ed
Top achievements
Rank 2
answered on 13 Apr 2012, 08:23 PM
How did you create your calculated column qty * unit price ?
Tags
Grid
Asked by
Rajesh SV
Top achievements
Rank 1
Answers by
Behtash Moradi
Top achievements
Rank 1
Rajesh SV
Top achievements
Rank 1
Ed
Top achievements
Rank 2
Share this question
or