Setting and Changing RadNumericTextBox Positive and negative patterns Through Client Side

5 posts, 0 answers
  1. rajesh
    rajesh avatar
    15 posts
    Member since:
    Nov 2010

    Posted 24 Jun 2011 Link to this post

    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
  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 29 Jun 2011 Link to this post

    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.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Steven
    Steven avatar
    4 posts
    Member since:
    Oct 2012

    Posted 22 Oct in reply to Vasil Link to this post

    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();
                    }
                }
  5. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 24 Oct Link to this post

    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.
  6. Steven
    Steven avatar
    4 posts
    Member since:
    Oct 2012

    Posted 24 Oct in reply to Vasil Link to this post

    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");
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017