I try to format my tooltip numbers to achieve the following results:
15327 -->15,327
1.034234 --> 1.034
1.02 --> 1.02
Unfortunately, whatever i do i am getting trailing zeroes, such as 1.020
I tried few ways, for example:
lineThird.TooltipsAppearance.ClientTemplate = "#=series.name# (" & IIf(strDollarsTons = "tons", "", "$") & "#= kendo.format(\'{0:N3}\', value)#" & IIf(strDollarsTons = "tons", " ktons", "M") & ")"
also,
"#= kendo.parseFloat(value)#"
"#= kendo.format(\'{0:#,###,###.###}\', value)#"
"#= kendo.format(\'{0:N}\', value)#"
Please help
10 Answers, 1 is accepted
You can try these lines:
kendo.format({0:"#,#.###"}, value)
kendo.format({0:"#,###,###.###"}, value)
More details are available at https://docs.telerik.com/kendo-ui/framework/globalization/numberformatting.
Regards,
Rumen
Progress Telerik
Rumen,
In my original post i outlined that tried this approach. It is conceivable that i format it incorrectly in vb.
Should it look like the following?
lineThird.TooltipsAppearance.ClientTemplate = "#=series.name# (" & "#= kendo.format({0:"#,###,###.###"}, value) #" & ")"
When you use the kendo.format() method from code behind you should ensure the quotes are escaped with double backslashes. For example #=kendo.format(\\'{0:N2}\\', value)#. More information is available in this article - http://www.telerik.com/help/aspnet-ajax/htmlchart-troubleshooting-escaping-special-symbols.html.
Best regards,
Rumen
Progress Telerik
Here is an example of how to set a Kendo template via a VB.NET codebehind:
Protected
Sub
Page_Load(sender
As
Object
, e
As
EventArgs)
Handles
Me
.Load
Dim
series = TryCast(RadHtmlChart1.PlotArea.Series(0), BarSeries)
Dim
formatString =
"#=dataItem.ProductName#<br />#=dataItem.Manufacturer# (#= kendo.format(\'{0:C2}\', dataItem.Price)#)"
series.TooltipsAppearance.ClientTemplate = formatString
End
Sub
You can also find attached a sample project, which you can use as a base to proceed with your implementation.
Regards,
Rumen
Progress Telerik
Rumen, your example obviously will work, but it is not the answer to the question i asked. I wanted flexible way to format numbers without trailing zeroes.
For example if i will use solution similar to one you recommended : {0:N3},
i will get the following results (trailing zeroes):
15327 -->15,327.000
1.034234 --> 1.034
1.02 --> 1.020
However, what i am looking for is the following:
15327 -->15,327
1.034234 --> 1.034
1.02 --> 1.02
See this article - https://docs.telerik.com/kendo-ui/framework/globalization/numberformatting#custom.
Hope this helps.
Regards,
Rumen
Progress Telerik
Rumen,
It still does not work.
I tried the following:
lineThird.TooltipsAppearance.ClientTemplate = "#=series.name# (" & "#= kendo.toString(value,\'#,###,###.###\') #" & ")"
Can you please create micro project that will assign ClientTemplate on back end the way you suggest?
Thank you
Dim formatString = "#= kendo.toString(123456,\'\\#,\\#\') #"
Please, find attached my test project.
Regards,
Rumen
Progress Telerik
That looks good
Thank you