[CLOSED] Numberfiel in Brazilian currency

  1. #1

    [CLOSED] Numberfiel in Brazilian currency

    how can I do when entering a value in a Numberfiel it matches the format in Brazilian currency?


    example: R$ 77.600,00

    Tks.

    Ulisses
    Last edited by Daniil; May 08, 2015 at 7:48 PM. Reason: [CLOSED]
  2. #2
    Hi @ucaneto,

    Unfortunately, NumberField doesn't support formatting.

    You could try with a TextField if appropriate. The best solution we could suggest is to format on blur and remove formatting on focus.

    Example
    <%@ Page Language="C#" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server">
                <Listeners>
                    <DocumentReady Handler="Ext.util.Format.currencySign = 'R$';" />
                </Listeners>
            </ext:ResourceManager>
    
            <ext:TextField runat="server" MaskRe="[0-9\.]">
                <Listeners>
                    <Focus Handler="this.setValue(this.getValue().replace(/[R$\,]/g, ''));" />
                    <Blur Handler="this.setRawValue(Ext.util.Format.currency(this.getRawValue()));" />
                </Listeners>
            </ext:TextField>
        </form>
    </body>
    </html>
  3. #3
    Thank Daniil, so one more doubt has as I change the point comma?
    in Brazil the currency is so R $ 77,106.25 and R $ 77,106.25 not.


    The Ext.net support is the best of all.
  4. #4
    Thank you for the find words!

    There are the thousandSeparator and decimalSeparator settings.
    http://docs.sencha.com/extjs/4.2.1/#...cimalSeparator
    http://docs.sencha.com/extjs/4.2.1/#...usandSeparator

    Example
    <%@ Page Language="C#" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    
        <script>
            var onDocumentReady = function () {
                Ext.apply(Ext.util.Format, {
                    thousandSeparator: ".",
                    decimalSeparator: ",",
                    currencySign: "R$"
                });
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server">
                <Listeners>
                    <DocumentReady Fn="onDocumentReady" />
                </Listeners>
            </ext:ResourceManager>
    
            <ext:TextField runat="server" MaskRe="[0-9,]">
                <Listeners>
                    <Focus Handler="this.setValue(this.getValue().replace(/[R$\.]/g, ''));" />
                    <Blur Handler="this.setRawValue(Ext.util.Format.currency(this.getRawValue().replace(',', '.')));" />
                </Listeners>
            </ext:TextField>
        </form>
    </body>
    </html>

Similar Threads

  1. Replies: 7
    Last Post: Apr 27, 2016, 12:18 AM
  2. Brazilian phone number format
    By RaphaelSaldanha in forum Examples and Extras
    Replies: 2
    Last Post: Jan 07, 2015, 3:04 PM
  3. Currency Format
    By sateeshdasarikapil in forum 2.x Help
    Replies: 1
    Last Post: Dec 30, 2014, 6:56 AM
  4. currency euro
    By maxdiable in forum 1.x Help
    Replies: 1
    Last Post: Jul 28, 2009, 10:53 AM
  5. Currency format
    By Gianni in forum 1.x Help
    Replies: 2
    Last Post: Jul 20, 2009, 5:32 AM

Posting Permissions