This question is locked. New answers and comments are not allowed.
Im binding to a grid using Ajax and im using .ClientTemplates to display each column. The problem im running into is that I need to format the values of the columns but not sure how to go about it. Now the problem may have to do with the fact
that im putting a label in the column. The reason im using a label is
that I will need to toggle the display of the value but still want the
column to display in the grid. It seems the hidden and visible
properties hide the column which is not what im after.
Here is an example of a column.
Ideally I would like to format the value of <#=EmptyRL#>. Something like:
String.Format("{0:n0}", <#=EmptyRL#>)
Of course this does not work
Any ideas/suggestions?
Here is an example of a column.
columns.Bound(o => o.EmptyRL) .ClientTemplate("<label " + "style='<#= IsRaillinkValid ? '' : 'display:none;'#>'>" + "<#=EmptyRL#>" + "</label>") .Title("Empty RL") .Width(100) .HtmlAttributes(new { style = "text-align:right" });Ideally I would like to format the value of <#=EmptyRL#>. Something like:
String.Format("{0:n0}", <#=EmptyRL#>)
Of course this does not work
Any ideas/suggestions?
9 Answers, 1 is accepted
0
Accepted
Hello lmf232s,
Atanas Korchev
the Telerik team
You can try this:
.ClientTemplate("<#= $.telerik.formatString('{0:n0}', EmptyRL) #>")
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
lmf232s
Top achievements
Rank 1
answered on 08 Nov 2010, 10:47 PM
Atanas,
What you suggested actually returns the format appened to the string.
Example:
ClientTemplate("<#= $.telerik.formatString('{0:n0}', EmptyRL) #>")
Returns:
n2324
Instead of:
2,324
Any ideas?
Edit:
Maybe this is just me, if I remove the 0 after the n then if formats fine but I get 2 decimal places. I was indicating n0 so the number would be formated with commas but no decimals. The n0 is what does not seem to work. The same goes for 0:c, if I leave as is then if formats but 0:c0 does not format. Gives a c323232.
What you suggested actually returns the format appened to the string.
Example:
ClientTemplate("<#= $.telerik.formatString('{0:n0}', EmptyRL) #>")
Returns:
n2324
Instead of:
2,324
Any ideas?
Edit:
Maybe this is just me, if I remove the 0 after the n then if formats fine but I get 2 decimal places. I was indicating n0 so the number would be formated with commas but no decimals. The n0 is what does not seem to work. The same goes for 0:c, if I leave as is then if formats but 0:c0 does not format. Gives a c323232.
0
Hello lmf232s,
Standard formats of "0:N3" is not supported for the time being. In order to achive your goal you can try this code snippet:
All the best,
Georgi Krustev
the Telerik team
Standard formats of "0:N3" is not supported for the time being. In order to achive your goal you can try this code snippet:
.ClientTemplate("<#= $.telerik.formatString('{0:0}', EmptyRL) #>")All the best,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
lmf232s
Top achievements
Rank 1
answered on 09 Nov 2010, 03:09 PM
Atanas,
That does not seem to work. Its not a huge problem so for now I'll just stick with {0:n} and hopefully in the future this is something that gets implemented and I can address it then.
Thanks,
lmf232s
That does not seem to work. Its not a huge problem so for now I'll just stick with {0:n} and hopefully in the future this is something that gets implemented and I can address it then.
Thanks,
lmf232s
0
lmf232s
Top achievements
Rank 1
answered on 10 Feb 2011, 12:07 AM
I just wanted to see if this has been looked at and/or if there is some sort of a work around.
I still have a field that I would like to format as a number (in order to get commas 1,000) but I don't want decimal places. Currently my only option seems to be .Format("{0:n}") which displays as 1,000.00.
Any ideas?
Im using Ajax Bindings
I still have a field that I would like to format as a number (in order to get commas 1,000) but I don't want decimal places. Currently my only option seems to be .Format("{0:n}") which displays as 1,000.00.
Any ideas?
Im using Ajax Bindings
0
Accepted
Hello Larry,
Regards,
Georgi Krustev
the Telerik team
In order to achieve your goal I will suggest you use this format:
columns.Bound(p => p.UnitsInStock).Width(130).Format("{0:#,##0}");Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
lmf232s
Top achievements
Rank 1
answered on 10 Feb 2011, 03:45 PM
Thanks Georgi!
0
Chandra Thumburu
Top achievements
Rank 1
answered on 03 Nov 2011, 12:59 AM
Hi Georgi Krustev,
For this, columns.Bound(p => p.Price).Format("{0:$#,##0;($#,##0);$0}")
if Price is 1525.99 then it displays $1,526
if Price is 0 then it displays $0
but if Price is 25.99 it display $,26. Note: Look at the ',' (i.e., Comma symbol) after $ and before 26.
Similarly if Price is 256.99 it display $,257. Note: Look at the ',' (i.e., Comma symbol) after $ and before 257
Please let me know about how to fix this issue.
For this, columns.Bound(p => p.Price).Format("{0:$#,##0;($#,##0);$0}")
if Price is 1525.99 then it displays $1,526
if Price is 0 then it displays $0
but if Price is 25.99 it display $,26. Note: Look at the ',' (i.e., Comma symbol) after $ and before 26.
Similarly if Price is 256.99 it display $,257. Note: Look at the ',' (i.e., Comma symbol) after $ and before 257
Please let me know about how to fix this issue.
0
Hello Chandra,
Georgi Krustev
the Telerik team
This is a known issue, which I am glad to inform is already addressed. You can try the latest internal build of the Telerik Extensions for ASP.NET MVC, which includes the fix.
Georgi Krustev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now