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

Setting and Changing RadNumericTextBox Positive and negative patterns Through Client Side

4 Answers 123 Views
Input
This is a migrated thread and some comments may be shown as answers.
rajesh
Top achievements
Rank 1
rajesh asked on 24 Jun 2011, 12:05 PM
hi, 
i just want to set and change the Positive and negative patterns  for radnumeric textbox through Client Side for ex: currency .
i dont have any idea abt it...please help me in this Regard .


Thanks and Regards 

rajesh

4 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 29 Jun 2011, 08:17 AM
Hello rajesh,

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.

0
Steven
Top achievements
Rank 1
answered on 22 Oct 2016, 11:21 PM

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();
                }
            }
0
Vasil
Telerik team
answered on 24 Oct 2016, 01:51 PM
Hello Steven,

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;
And then change the value of Units to 123.456
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
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
0
Steven
Top achievements
Rank 1
answered on 24 Oct 2016, 03:40 PM

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");
Tags
Input
Asked by
rajesh
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Steven
Top achievements
Rank 1
Share this question
or