This is a migrated thread and some comments may be shown as answers.

Pasting into RadNumeric

4 Answers 68 Views
Input
This is a migrated thread and some comments may be shown as answers.
Lukasz Kalbarczyk
Top achievements
Rank 1
Lukasz Kalbarczyk asked on 21 Apr 2010, 11:51 AM
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?

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Apr 2010, 01:44 PM
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.
0
Lukasz Kalbarczyk
Top achievements
Rank 1
answered on 23 Apr 2010, 09:44 AM
It does nothing or I can't see it... Still same effects as before.
0
Accepted
Dimo
Telerik team
answered on 26 Apr 2010, 10:33 AM
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.
0
Lukasz Kalbarczyk
Top achievements
Rank 1
answered on 26 Apr 2010, 11:28 AM
Nice, thanks :)
Tags
Input
Asked by
Lukasz Kalbarczyk
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Lukasz Kalbarczyk
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or