
Cheng Lim Sek
Top achievements
Rank 1
Cheng Lim Sek
asked on 20 May 2010, 04:10 AM
Hi,
I have problem for the decimal digits I have set.
Currently I have few setting for numerictextbox:
<telerik:radnumerictextbox skinid="Percentage" enableenbeddedskins="false" maxvalue="100" minvalue="0" numericformat-allowrounding="false" numericformat-decimaldigits="2"/>
<telerik:radnumerictextbox skinid="Decimal2Digits" enableenbeddedskins="false" maxvalue="100" minvalue="0" numericformat-allowrounding="false" numericformat-decimaldigits="2"/>
<telerik:radnumerictextbox skinid="Decimal4Digits" enableenbeddedskins="false" maxvalue="100" minvalue="0" numericformat-allowrounding="false" numericformat-decimaldigits="4"/>
The problem I face is that, even I have set numericformat-decimaldigits="2" or numericformat-decimaldigits="4", if I type 12.30, it will show me 12.3.
Is there a solution that it will show me exactly 2 decimaldigits (12.30) if I type, 12.3 or 12.30?
Or exactly 4 decimal digits (12.3330) if I type, 12.333 or 12.3330?
I have problem for the decimal digits I have set.
Currently I have few setting for numerictextbox:
<telerik:radnumerictextbox skinid="Percentage" enableenbeddedskins="false" maxvalue="100" minvalue="0" numericformat-allowrounding="false" numericformat-decimaldigits="2"/>
<telerik:radnumerictextbox skinid="Decimal2Digits" enableenbeddedskins="false" maxvalue="100" minvalue="0" numericformat-allowrounding="false" numericformat-decimaldigits="2"/>
<telerik:radnumerictextbox skinid="Decimal4Digits" enableenbeddedskins="false" maxvalue="100" minvalue="0" numericformat-allowrounding="false" numericformat-decimaldigits="4"/>
The problem I face is that, even I have set numericformat-decimaldigits="2" or numericformat-decimaldigits="4", if I type 12.30, it will show me 12.3.
Is there a solution that it will show me exactly 2 decimaldigits (12.30) if I type, 12.3 or 12.30?
Or exactly 4 decimal digits (12.3330) if I type, 12.333 or 12.3330?
5 Answers, 1 is accepted
0

Cheng Lim Sek
Top achievements
Rank 1
answered on 20 May 2010, 04:39 AM
Hi,
For the problem i mention, I found out that it happen if I set numericformat-allowrounding="false".
Why after I set numericformat-allowrounding="false", it will show me 12.333 instead of 12.3330 while I have set numericformat-decimaldigits="4"?
I don't allow the number to round up and I would like to always show 4 decimal digits.
How can I do this?
Another question, if I set the type="Currency", how can I remove or don't show currency type like $12.33?
For the problem i mention, I found out that it happen if I set numericformat-allowrounding="false".
Why after I set numericformat-allowrounding="false", it will show me 12.333 instead of 12.3330 while I have set numericformat-decimaldigits="4"?
I don't allow the number to round up and I would like to always show 4 decimal digits.
How can I do this?
Another question, if I set the type="Currency", how can I remove or don't show currency type like $12.33?
0
Hi Cheng Lim Sek,
The observed behavior is by design. You can use the following approach:
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.
The observed behavior is by design. You can use the following approach:
<%@ 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:RadNumericTextBox
ID
=
"rdTextBox"
runat
=
"server"
>
<
NumberFormat
AllowRounding
=
"false"
DecimalDigits
=
"3"
/>
<
ClientEvents
OnBlur
=
"addZeros"
OnValueChanged
=
"addZeros"
/>
</
telerik:RadNumericTextBox
>
<
script
type
=
"text/javascript"
>
function addZeros(sender, args)
{
var decimalPart = sender._textBoxElement.value.split(".")[1];
var zeros = "";
if (decimalPart && decimalPart.length <
sender.get_numberFormat
().DecimalDigits)
{
for (var
j
=
0
; j < sender.get_numberFormat().DecimalDigits - decimalPart.length; j++)
{
zeros += "0";
}
sender._textBoxElement.value
= sender._textBoxElement.value.split(".")[0] + "." + decimalPart + zeros;
}
else if (!decimalPart && sender.get_numberFormat().DecimalDigits > 0)
{
for (var j = 0; j <
sender.get_numberFormat
().DecimalDigits; j++)
{
zeros += "0";
}
sender._textBoxElement.value
= sender._textBoxElement.value + "." + zeros;
}
}
</script>
</
form
>
</
body
>
</
html
>
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

Cheng Lim Sek
Top achievements
Rank 1
answered on 20 May 2010, 11:55 AM
Hi,
Thank for the answer.
How about the second question that I set it type="Currency" but I don't want to show any curreny type like "$"?
Thank for the answer.
How about the second question that I set it type="Currency" but I don't want to show any curreny type like "$"?
0
Hello Cheng Lim Sek,
Well, if you don't want a currency sign, just don't set Type="Currency".
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.
Well, if you don't want a currency sign, just don't set Type="Currency".
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

Carlos Contreras
Top achievements
Rank 1
answered on 08 Oct 2010, 08:03 PM
Hi Cheng Lim Sek!
I'm not sure about why do you set the Type property to "Currency" if you don't want the money symbol to be shown. However, in order to not display that character/symbol, even if you have set Type=Currency, you have to modify two properties:
PositivePattern and NegativePattern. You can find them on the NumberFormat properties group.
When Type="Currency", their values are $n and ($n) respectively, and when Type=Number, their values are n and (n). Got it? ;)
All you have to do, is remove the $ symbol!
I hope it helps you.
Good Luck!