NumberFormat including the character 'n'

9 posts, 0 answers
  1. Östemar
    Östemar avatar
    8 posts
    Member since:
    Oct 2012

    Posted 21 Oct 2008 Link to this post

    Hi,

    I'm having some issues with the number format of RadNumericTextBox. If I for example want the NumberFormat-PositivePattern to be "n tons" and set the value to 123 the control's text gets rendered by the server as "123 to123s".

    If I go to the field and then switch the focus to another field the javascript side of the formatting corrects the text to "123 tons".

    If I use "tons n" as the format, the server renders "to123s 123" and the javascript renders "to123s n".

    Clearly the server and client code are interpreting my format differently. So the bottom line seems to be that the server switches all occurences of 'n' to the value while the javascript switches only the first occurence of 'n' to the value.

    I actually think the server does the correct thing (at least compared to the javascript). I think that the n in tons should be escaped by me somehow, but I can't find any mentioning of that in the manuals. The only thing I find is this text:

    "The characters other than n in a formatting pattern are literal symbols. If you use the dollar sign ("$") as a currency symbol, for example, currency values are formatted using that symbol regardless of the value of the Culture property."

    Could you spread some light on this issue?

    Regards,
    Martin
  2. Plamen Peshev
    Admin
    Plamen Peshev avatar
    886 posts

    Posted 21 Oct 2008 Link to this post

    Hi Martin,


    Indeed we must admit there is an issue with the PositivePattern property. We will do our best to have it fixed for the upcoming Q3 release, expected at the beginning of the next month. For the moment we could suggest you the following workaround:


            <div> 
            <script type="text/javascript"
            function Load(sender, args) 
            { 
                sender.updateDisplayValue(); 
            } 
            </script> 
            <telerik:RadNumericTextBox Value="123" ID="RadNumericTextBox1" runat="server"
                <ClientEvents OnLoad="Load" /> 
                <NumberFormat PositivePattern="n tons" /> 
            </telerik:RadNumericTextBox>         
            </div> 


    Thank you for bringing this issue to our attention. You Telerik points have been updated.


    Greetings,
    Plamen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Östemar
    Östemar avatar
    8 posts
    Member since:
    Oct 2012

    Posted 22 Oct 2008 Link to this post

    Hi Plamen,

    Thanks for a quick response. Just to be clear - it isn't just the PositivePattern that is causing a problem, the same goes for NegativePattern.

    When trying your workaround I found some more bugs regarding this issue. Your workaround with updateDisplayValue() works fine for the pattern "n tons", but for a pattern of, for example "tons n" it renders an empty string ("").

    So, to summarise my found issues (for both positive and negative patterns):
    1. The server side renders the value for every occurence of 'n'.
    2. The client side renders the value for the first n, which makes it impossible to have a pattern where the first n should be considered a literal.
    3. Calling updateDisplayValue() on ClientEvents-OnLoad renders empty text when the first character isn't an 'n'.
    4. Calling updateDispalyValue() on ClientEvents-OnLoad with a pattern of "nn" and value 123 renders "123 123n" which is so strange that I can't even find a reason. :-)
    I have no problems using the workaround since I want to display "n tons", but I just wanted to make sure that you got all the bugs in one fix. :-)

    Regards,
    Martin
  4. Östemar
    Östemar avatar
    8 posts
    Member since:
    Oct 2012

    Posted 22 Oct 2008 Link to this post

    "I have no problems using the workaround since I want to display "n tons", but I just wanted to make sure that you got all the bugs in one fix. :-)"

    I take that back. I just found another issue. I have the following code:

    <script type="text/javascript" language="javascript">
    <!--
    function FixNumericTextBoxFormat(sender, args) {
      sender.updateDisplayValue();
    }
    -->
    </script>
    <telerik:RadNumericTextBox
    ID="RadNumericTextBox1" runat="server"
    MinValue="0" MaxLength="7"
    Width="6em" Skin="Office2007"
    SelectionOnFocus="SelectAll" NumberFormat-DecimalDigits="0"
    NumberFormat-GroupSeparator=" "
    NumberFormat-PositivePattern="n tons"
    EmptyMessage="<tons>"
     Value="1234"
    ClientEvents-OnLoad="FixNumericTextBoxFormat" />

    This is following your workaround.The problem is that when the page is loaded and FixNumericTextBoxFormat has done its job the string is formatted as "1 tons". If I then click on the box the value reads 1234 (which is correct). When I leave the box it gets formatted as "1234 tons". So clearly the updateDisplayValue() isn't the only thing happening when I leave the text box. I verified that inside the FixNumericTextBoxFormat() function the sender.get_Value() is 1234 and not 1.

    So right now, even the workaround fails for me.

  5. Plamen Peshev
    Admin
    Plamen Peshev avatar
    886 posts

    Posted 27 Oct 2008 Link to this post

    Hello Martin,

    The issue will be fixed for the next release. Unfortunately, we would not be able to provide a workaround for it.
    Please excuse us for the inconvenience.


    Kind regards,
    Plamen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Thomas Gross
    Thomas Gross avatar
    7 posts
    Member since:
    May 2010

    Posted 14 Nov 2010 Link to this post

    I have a problem with formating string for RadNumericTextBox
    i want to use the charater n in the unit.
    the unit is [Wh/ton-km]. (the value in the following example 35,0)
    My formating string: "n Wh/ton-km"
    the result: n Wh/to35,0-km

    Your documentions
    The characters other than n in a formatting pattern are literal symbols

    I find the following link for this problem
    http://www.telerik.com/community/forums/aspnet-ajax/input/numberformat-including-the-character-n.aspx
    you said in Oct 2008 that you fix this problem with the next version.

    Do you have such a fix now?

    Greetings
    thomas

  7. Martin
    Admin
    Martin avatar
    820 posts

    Posted 18 Nov 2010 Link to this post

    Hello Thomas,

    Indeed the reported issue is still observed. I have contacted our developers and the feedback I got is that they would need some time to deeper investigate the cause of the problem. Note that RadNumericTextBox is a sophisticated component and implementing a stable and working fix requires some time for research and testing.

    In your particular scenario the problem comes form the "n-" character sequence that is part of your positive pattern. As temporary workaround you can modify your pattern by separating the "n" and "-" symbols. For example adding spaces around the "-" character works as expected on my side:

    <telerik:RadNumericTextBox Value="35" ID="RadNumericTextBox1" runat="server">
        <NumberFormat PositivePattern="n Wh/ton - km" NegativePattern="-n Wh/ton - km" />
    </telerik:RadNumericTextBox>
     
    Please excuse us for the inconvenience.

    Kind regards,
    Martin
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  8. Vassilis
    Vassilis avatar
    1 posts
    Member since:
    Jul 2012

    Posted 21 Nov 2016 in reply to Martin Link to this post

    Hi I tried to work based on the example above. When the entry is displayed I see the proper format. When I type something and I tab out the formatting is lost?

    <telerik:RadNumericTextBox Value="35" ID="RadNumericTextBox1" runat="server">
        <NumberFormat PositivePattern="n Wh/ton - km" NegativePattern="-n Wh/ton - km" />
    </telerik:RadNumericTextBox>

  9. Vasil
    Admin
    Vasil avatar
    1596 posts

    Posted 21 Nov 2016 Link to this post

    Hello Vassilis,

    I just tested your markup with the latest version of the controls, and it works correct. Are you using old version? Do you have additional scripts in your page that affect the numeric?

    Regards,
    Vasil
    Telerik by Progress
    Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
Back to Top