4 Answers, 1 is accepted
You could use get_numberFormat() property of the RadNumericTextBox client object to access the number format object. Here is an example how you could change the negative and positive patterns:
$find(
"RadNumericTextBox1"
).get_numberFormat().NegativePattern =
"$(-) n"
;
$find(
"RadNumericTextBox1"
).get_numberFormat().PositivePattern =
"$(+) n"
;
See the resources bellow for more information:
http://www.telerik.com/help/aspnet-ajax/input-client-side-numberformat.html
http://www.telerik.com/help/aspnet-ajax/input-numerictextbox-formatting-numeric-values.html
http://www.telerik.com/help/aspnet-ajax/input-client-side-radnumerictextbox.html
Regards,
Vasil
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
I know this is an old post, but I'm trying to change a RadNumericTextbox formatting client side and I followed the code above and it seems to be working but when I type in a number I get the previous format, set from the server side. I examined the .get_numberFormat() object after setting it and it shows the correct values, but the behavior is from before the format was reset. Any ideas?
function
OnCalcTypeChange(sender, eventArgs
{
var
entityKeyName = $find(
"<%=RadGridMultiIncomeSummary.ClientID%>"
).get_masterTableView().get_dataItems()[0].findControl(
"txtCurrentAmount"
);
var
txtBoxId = entityKeyName._clientID;
var
item = eventArgs.get_item();
if
(item.get_text() ==
'A'
)
{
$find(txtBoxId).get_numberFormat().NegativePattern =
"$ -n"
;
$find(txtBoxId).get_numberFormat().PositivePattern =
"$ n"
;
$find(txtBoxId).get_numberFormat().DecimalDigits = 0;
}
else
{
$find(txtBoxId).get_numberFormat().NegativePattern =
"-n%"
;
$find(txtBoxId).get_numberFormat().PositivePattern =
"n%"
;
$find(txtBoxId).get_numberFormat().DecimalDigits = 2;
var
nf = $find(txtBoxId).get_numberFormat();
}
}
I just tested this on our demos, and seems to be working.
Navigate to: http://demos.telerik.com/aspnet-ajax/numerictextbox/overview/defaultcs.aspx
And type in the console:
var
format = $find(
"ctl00_ContentPlaceholder1_RadNumericTextBox1"
).get_numberFormat();
format.PositivePattern =
"$ n"
;
format.DecimalDigits = 3;
Then you will get "$ 123.456" as visible value when you blur.
Could you share with us more details about the problem?
Regards,
Vasil
Telerik by Progress
Thank you Vasil for the quick reply. Sorry I left out, this is all happening in a RadGrid. Turns out the issue is the line below. It's pulling the first row "[0]" I need to find out a way to determine which row I need (it varies) and then feed that to the client side. Anyway that's not your problem, it's mine, thank you very much for your help. - Steven
var
entityKeyName = $find(
"<%= RadGridMultiIncomeSummary.ClientID%>"
).get_masterTableView().get_dataItems()[0].
(
"txtCurrentAmount"
);