Trailing zeroes in Tooltip Number Format

11 posts, 1 answers
  1. David
    David avatar
    221 posts
    Member since:
    Mar 2014

    Posted 18 Oct Link to this post

    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

  2. Rumen
    Admin
    Rumen avatar
    13278 posts

    Posted 23 Oct Link to this post

    Hello,

    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
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. David
    David avatar
    221 posts
    Member since:
    Mar 2014

    Posted 23 Oct in reply to Rumen Link to this post

    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) #" & ")"

  4. Rumen
    Admin
    Rumen avatar
    13278 posts

    Posted 26 Oct Link to this post

    Hi David,

    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
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. David
    David avatar
    221 posts
    Member since:
    Mar 2014

    Posted 26 Oct in reply to Rumen Link to this post

    Unfortunately "#=series.name# ($#= kendo.format(\\'{0:#,###,###.#####}\\', value)#M)" does not work
  6. Rumen
    Admin
    Rumen avatar
    13278 posts

    Posted 31 Oct Link to this post

    Hello,

    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
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  7. David
    David avatar
    221 posts
    Member since:
    Mar 2014

    Posted 31 Oct in reply to Rumen Link to this post

    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

  8. Rumen
    Admin
    Rumen avatar
    13278 posts

    Posted 02 Nov Link to this post

    Use kendo.toString(13423532327.230,'##,#.###') instead of kendo.format() to produce "13,423,532,327.23".

    See this article - https://docs.telerik.com/kendo-ui/framework/globalization/numberformatting#custom.

    Hope this helps.

    Regards,
    Rumen
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  9. David
    David avatar
    221 posts
    Member since:
    Mar 2014

    Posted 02 Nov in reply to Rumen Link to this post

    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

     

  10. Answer
    Rumen
    Admin
    Rumen avatar
    13278 posts

    Posted 08 Nov Link to this post

    To make it working in VB.NET you have to escape the # symbols too:

    Dim formatString = "#= kendo.toString(123456,\'\\#,\\#\') #"

    Please, find attached my test project.

    Regards,
    Rumen
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  11. David
    David avatar
    221 posts
    Member since:
    Mar 2014

    Posted 09 Nov in reply to Rumen Link to this post

    That looks good

    Thank you

Back to Top