Donald McLean
Top achievements
Rank 2
Donald McLean
asked on 11 May 2010, 07:01 PM
I have been working with this issue for a couple of days now with not much success. I have an application that keeps tracks of permits for municipalities. I have different tabs/pages for the different parts of the permit. On the Site tab, I have RadNumericTextBox set up for the Area, the issue I am having is this say I enter 245.0123, then go to a different tab so it will save it into the database. I come back and everything is the same. I navigate to different tab again, and when I check the database it has now saved it as 245.1230. It only seems to do it if there is a 0 next to the decimal, if there is any other number there it works fine and it doesn't change the number. Any help would be greatly appreciated.
function stripNumbersAfter4Decimals(sender, args)
{
var val = String(args.get_newValue());
if (val.length - val.indexOf('.') > 4)
args.set_newValue(val.substr(0, val.indexOf('.') + 5));
}
<telerik:RadNumericTextBox ID="rnumArea" runat="server" MinValue="0" Type="Number" Width="140px" ClientEvents-OnValueChanging="stripNumbersAfter4Decimals">
<NumberFormat DecimalDigits="4" KeepNotRoundedValue="false" />
</telerik:RadNumericTextBox>
function stripNumbersAfter4Decimals(sender, args)
{
var val = String(args.get_newValue());
if (val.length - val.indexOf('.') > 4)
args.set_newValue(val.substr(0, val.indexOf('.') + 5));
}
<telerik:RadNumericTextBox ID="rnumArea" runat="server" MinValue="0" Type="Number" Width="140px" ClientEvents-OnValueChanging="stripNumbersAfter4Decimals">
<NumberFormat DecimalDigits="4" KeepNotRoundedValue="false" />
</telerik:RadNumericTextBox>
7 Answers, 1 is accepted
0
Hello Donald,
We fixed a similar issue recently. Please try using the latest RadControls internal build and let us know if the problem persists.
http://www.telerik.com/account/downloads/internal-builds.aspx
Kind regards,
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.
We fixed a similar issue recently. Please try using the latest RadControls internal build and let us know if the problem persists.
http://www.telerik.com/account/downloads/internal-builds.aspx
Kind regards,
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
Donald McLean
Top achievements
Rank 2
answered on 12 May 2010, 05:01 PM
I tried the latest build and it fixed the problem I was having yet caused another. I set lets the site depth to be 245.0134 when I navigate away and comback the database doesn't change which is good but I get extroneous digits appended after the decimal. I have tried various JavaScript solutions and various combinations of field parameters and all fail to get the intended look and feel. I want a valid number to have no more then 4 decimal places if they enter 2.43 it should show 2.43 not 2.4300 and if they enter 2.123456 it should truncate to 2.1234 and not round it to 2.1235.
Here is the javascript I am using to get close to the behavior I want.
Here is the aspx
This is the closest I have been able to get however this doesn't completely solve the problem, when I do this and enter 245.0134, and switch tabs, database shows 245.0134 but yet the display shows 245.0133, when I click on the box it shows the right value.
Any help would be greatly appreciated.
Here is the javascript I am using to get close to the behavior I want.
var numDecimals = 4; function MyValueChanged(sender, args) |
{ |
var v = args.get_newValue().toString(); |
ModifyValue2(sender, v); |
} |
function MyLoad(sender, args) |
{ |
var v = sender.get_value().toString(); |
ModifyOnLoad(sender, v); |
} |
function MyBlur(sender, args) |
{ |
var v = sender.get_value().toString(); |
ModifyValue2(sender, v); |
} |
function ModifyValue(tb, v) |
{ |
if (v.indexOf(".") != -1) |
{ |
var parts = v.split("."); |
if (parts[1].length < tb.get_numberFormat().DecimalDigits) |
{ |
window.setTimeout(function(){tb._textBoxElement.value = v;}, 1); |
} |
} |
} |
function ModifyOnLoad(tb, v) |
{ |
var e = numDecimals + 1; |
var diff = v.length - v.indexOf('.'); |
if (diff > numDecimals) |
{ |
v = (v.substr(0, v.indexOf('.') + e)); |
} |
if (v.indexOf(".") != -1) |
{ |
while(v[v.length-1] == '0') |
{ |
v = v.substring(0, v.length-1); |
} |
} |
window.setTimeout(function(){tb._textBoxElement.value = v;}, 1); |
} |
Here is the aspx
<telerik:RadNumericTextBox ID="rnumDepth" runat="server" MinValue="0" Width="140px"> |
<NumberFormat DecimalDigits="4" KeepNotRoundedValue="false" AllowRounding="true" /> |
<ClientEvents OnLoad="MyLoad" OnValueChanged="MyValueChanged" OnBlur="MyBlur" /> |
</telerik:RadNumericTextBox> |
This is the closest I have been able to get however this doesn't completely solve the problem, when I do this and enter 245.0134, and switch tabs, database shows 245.0134 but yet the display shows 245.0133, when I click on the box it shows the right value.
Any help would be greatly appreciated.
0
Hello Donald,
If I understand you correctly, you should be able to achieve the desired behavior with the following configuration. No additional Javascript coding is required.
<telerik:RadNumericTextBox ID="rntb1" runat="server">
<NumberFormat AllowRounding="false" DecimalDigits="4" />
</telerik:RadNumericTextBox>
Greetings,
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.
If I understand you correctly, you should be able to achieve the desired behavior with the following configuration. No additional Javascript coding is required.
<telerik:RadNumericTextBox ID="rntb1" runat="server">
<NumberFormat AllowRounding="false" DecimalDigits="4" />
</telerik:RadNumericTextBox>
Greetings,
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
Donald McLean
Top achievements
Rank 2
answered on 14 May 2010, 02:28 PM
Thanks for the reply I tried that and it didn't quite work. Everything on the page works fine until you navigate away from the page so it saves the change to the database and come back to the page then it gets some wierd rounding issue happening for example. I set it to 245.1234 navigate away and comback to the page and it not shows 245.123397827148 when you click on the box to change the value then it changes to 245.1233 which is the wrong value for the decimal.
I tried 245.012, navigate away, now 245.011993408203 click on the box and becomes 245.0119 yet the database shows the right value. I can't release the software this way if I can't find away to make this work going to have to use a regular textbox and hack it using javascipt to get it to work.
I tried 245.012, navigate away, now 245.011993408203 click on the box and becomes 245.0119 yet the database shows the right value. I can't release the software this way if I can't find away to make this work going to have to use a regular textbox and hack it using javascipt to get it to work.
0
Hello Donald,
We have researched and addressed such an issue in the past. What version are you using? Did you try your scenario with the latest RadControls version?
Also, how exactly do you "come back" to the page - with the browser's "Back" button or in some other way?
Regards,
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.
We have researched and addressed such an issue in the past. What version are you using? Did you try your scenario with the latest RadControls version?
Also, how exactly do you "come back" to the page - with the browser's "Back" button or in some other way?
Regards,
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
Donald McLean
Top achievements
Rank 2
answered on 17 May 2010, 01:47 PM
I am using the latest build from you version 2010.1.415.35 and interms of how I am getting back to the page, I have a rad tabstrip setup for the navigation. I use it to move between the pages. Hopefully there is a simple fix for this issue. I remember having a similar issue with the reports.
I just tried a crazy fix based on the way I solved the rounding issue with the reports and it seems to work.
rnumFrontage.Value = double.Parse(string.Format("{0:#,0.####}", siteData.Frontage));
I used the string.Format to get around the similar rounding issue with the reports so it came to me it might solve this issue too. It seems to work like a charm. I just have to apply the fix to all the rad numeric text boxes.
I just tried a crazy fix based on the way I solved the rounding issue with the reports and it seems to work.
rnumFrontage.Value = double.Parse(string.Format("{0:#,0.####}", siteData.Frontage));
I used the string.Format to get around the similar rounding issue with the reports so it came to me it might solve this issue too. It seems to work like a charm. I just have to apply the fix to all the rad numeric text boxes.
0
Hello Donald,
I am still not sure how exactly the problem is reproduced. If you would like us to investigate it, please send a runnable demo, or modify the following test page until the unwanted behavior is exhibited:
All the best,
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.
I am still not sure how exactly the problem is reproduced. If you would like us to investigate it, please send a runnable demo, or modify the following test page until the unwanted behavior is exhibited:
<%@ Page Language="C#" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
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:RadTabStrip
ID
=
"RadTabStrip1"
runat
=
"server"
MultiPageID
=
"RadMultiPage1"
SelectedIndex
=
"0"
>
<
Tabs
>
<
telerik:RadTab
Text
=
"Tab 1"
/>
<
telerik:RadTab
Text
=
"Tab 2"
/>
</
Tabs
>
</
telerik:RadTabStrip
>
<
telerik:RadMultiPage
ID
=
"RadMultiPage1"
runat
=
"server"
SelectedIndex
=
"0"
>
<
telerik:RadPageView
ID
=
"RadPageView1"
runat
=
"server"
>
<
telerik:RadNumericTextBox
ID
=
"rntb1"
runat
=
"server"
>
<
NumberFormat
AllowRounding
=
"false"
DecimalDigits
=
"4"
/>
</
telerik:RadNumericTextBox
>
</
telerik:RadPageView
>
<
telerik:RadPageView
ID
=
"RadPageView2"
runat
=
"server"
>
RadPageView2
</
telerik:RadPageView
>
</
telerik:RadMultiPage
>
</
form
>
</
body
>
</
html
>
All the best,
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.