Pasting into RadNumeric

5 posts, 1 answers
  1. Lukasz Kalbarczyk
    Lukasz Kalbarczyk avatar
    24 posts
    Member since:
    Feb 2010

    Posted 21 Apr 2010 Link to this post

    I have a RadNumeric with:

    DecimalSeparator = ","
    GroupSeparator = " "
    DecimalDigits = 0
    AllowRounding = false

    I'm pasting the value by the [ctrl]+[v] sequence.
    When I'm pasting "8.5" - it is OK, value is beeing changed to 8.
    When I'm pasting "8,5" - it is NOT OK, value is beeing changed to... 85.

    I tried to set the OnValueChanging event, but the get_nevValue() method returns 85, OnBlur too...
    Is it possible to get the pasted value before it will be processed by the Control?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 22 Apr 2010 Link to this post

    Hello,

    I got it working as you expected when I added the following code. Give a try with this and see whether it helps you.

    JavaScript:
     
     <script type="text/javascript"
                function OnKeyPress1(sender, args) { 
                    sender._rejectRegExp = ""
                } 
    </script>  
    Attach OnKeyPress event to RadNumericTextBox

    Regards,
    Princy.
  3. Lukasz Kalbarczyk
    Lukasz Kalbarczyk avatar
    24 posts
    Member since:
    Feb 2010

    Posted 23 Apr 2010 Link to this post

    It does nothing or I can't see it... Still same effects as before.
  4. Answer
    Dimo
    Admin
    Dimo avatar
    8482 posts

    Posted 26 Apr 2010 Link to this post

    Hi Lukasz,

    I am afraid the described behavior is not supported out-of-the-box - the RadNumericTextBox accepts only one type of decimal separator, according to its culture and settings.

    Manipulating the clipboard data is not allowed due to security restrictions, so I suggest you the following.

    Depending on the control's decimal separator, you may need to reverse the Javascript logic (e.g. replace "." with "," or vice-versa)


    <%@ Page Language="C#" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     
    <head runat="server">
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <title>RadControls</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
     
    <telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server">
        <NumberFormat AllowRounding="false" DecimalDigits="0" GroupSeparator=" " />
        <ClientEvents OnValueChanging="MyValueChanging" />
    </telerik:RadNumericTextBox>
     
    <br /><br />
    8.5
    <br />
    8,5
     
    <script type="text/javascript">
     
    var textboxFlag = true;
     
    function MyValueChanging(sender, args)
    {
        if (!textboxFlag)
            return;
         
        var v = sender._textBoxElement.value;
        if (v.indexOf(",") != -1)
        {
            textboxFlag = false;
            var vn = v.replace(",", ".");
            sender._textBoxElement.value = vn;
            window.setTimeout(function(){sender.set_value(vn);textboxFlag = true;}, 1);
        }
    }  
     
    </script>
     
    </form>
    </body>
    </html>


    Best wishes,
    Dimo
    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.
  5. Lukasz Kalbarczyk
    Lukasz Kalbarczyk avatar
    24 posts
    Member since:
    Feb 2010

    Posted 26 Apr 2010 Link to this post

    Nice, thanks :)
Back to Top