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

[Solved] MVC Grid Footer

3 Answers 131 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Simon
Top achievements
Rank 1
Simon asked on 01 Mar 2012, 05:56 PM
Hi,

I am using the telerik MVC grid as follows:

......

columns.Bound(o => o.Charge)

.Aggregate(aggregates => aggregates.Sum())

.Width(115)

.Title(

 

"Charge")

 

.ClientTemplate(

 

"<#= FormattedCharge #>")

 

.ClientFooterTemplate(

 

"£ <#= $.telerik.formatString('{0:N}', Sum) #>")

 

.HeaderHtmlAttributes(

 

new { title = "Represents the total........" });

When I do this the total I get in the footer comes up, for example, as £ 16 or £ 2.99999999998. We would expect it to come out as £ 16.00 or £ 2.99. The type of "Charge" above is double.

Could you confirm that the syntax above is correct? If not, could you please provide the correct syntax.

Many thanks

 

3 Answers, 1 is accepted

Sort by
0
Dadv
Top achievements
Rank 1
answered on 02 Mar 2012, 09:41 AM
Hi,

try : {0:N2} 

ref : http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx 

Regards,
0
Simon
Top achievements
Rank 1
answered on 02 Mar 2012, 11:05 AM

Thanks - we have tried N2 (and C2) and practically every other combination but without success.

Is this a bug with telerik?
0
Dadv
Top achievements
Rank 1
answered on 02 Mar 2012, 12:19 PM
Perhaps the $.telerik.formatString don't take the round number.. you could probably use javascript instead :

Math.round(number).toFixed(2)
something like that : "£ <#= Math.round($.telerik.formatString('{0:N}', Sum)).toFixed(2) #>"

but i'm not really sure that telerik will  use it like a javascript function...

I'll do some test this afternoon 
Tags
General Discussions
Asked by
Simon
Top achievements
Rank 1
Answers by
Dadv
Top achievements
Rank 1
Simon
Top achievements
Rank 1
Share this question
or