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

[Solved] How to access sum of one column in ClientFooterTemplate in another column ClientFooterTemplate?

4 Answers 1175 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Arek
Top achievements
Rank 1
Arek asked on 17 Oct 2013, 09:35 PM
Hello,

I'm trying to access one SUM of a column in ClientFooterTemplate of another ClientFooterTemplate...

You can access the other's column's values in regular ClientTemplate but not in ClientFooterTemplate.

Example (Asp.Net MVC):

1.columns.Bound(cd => cd.Spend).Width(90)
2.    .ClientFooterTemplate("<span style='float:right'>#= kendo.format('{0:c}', sum) #</span>")
3.    .ClientTemplate("<span style='float:right'>#= kendo.format('{0:c}', Spend) #</span>");
4.columns.Bound(cd => cd.Cpc).Title("CPC").Width(75)
5.    .ClientFooterTemplate("<span style='float:right'>#= kendo.format('{0:N2}', Spend) #</span>")
6.    .ClientTemplate("<span style='float:right'>#= kendo.format('{0:N2}', Cpc) #</span>");
In the code above I'm trying to access Spend in row 5. Which is the sum in row 2.

Any ideas will be helpful.

And I'm just trying to get the other column's sum and if I'm successful the final calculation will be much more complex.


Thanks,
-Arek

4 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 21 Oct 2013, 10:36 AM
Hi Arek,

You can access another column's values through the data object, for example:  
columns.Bound(cd => cd.Spend).ClientFooterTemplate("Cpc sum: #=data.parent().Cpc.sum#")
columns.Bound(cd => cd.Cpc).ClientFooterTemplate("Spend sum: #=data.parent().Spend.sum#") 

Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
AndyRutter
Top achievements
Rank 2
answered on 03 Dec 2014, 09:49 AM
Hi,
This looked like exactly what I need however when using:
c.Bound(o => o.ForecastLitres).ClientFooterTemplate("#= kendo.format('{0:N0}', sum)#");
c.Bound(o => o.ActualVsForecast).ClientFooterTemplate("#=data.parent().ForecastLitres.sum#");

I get the following error:
Error: Object doesn't support property or method 'parent'

Has something changed with the latest controls?
I am using 2014.3.1119.545 Dev

Cheers
0
AndyRutter
Top achievements
Rank 2
answered on 03 Dec 2014, 09:52 AM
Hi,
This looked like exactly what I need, I am trying:
c.Bound(o => o.ForecastLitres).ClientFooterTemplate("#= kendo.format('{0:N0}', sum)#");
c.Bound(o => o.ActualVsForecast).ClientFooterTemplate("#=data.parent().ForecastLitres.sum#");

But am getting the followin error:
Error: Object doesn't support property or method 'parent'

Has anything changed in the latest version of the MVC controls?
I am using 2014.3.1119.545 Dev

Cheers
0
AndyRutter
Top achievements
Rank 2
answered on 03 Dec 2014, 10:15 AM
Ah nevermind, found the solution, just lose the parent():
c.Bound(o => o.ActualVsForecast).ClientFooterTemplate("#=data.ForecastLitres.sum#");
Tags
Grid
Asked by
Arek
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
AndyRutter
Top achievements
Rank 2
Share this question
or