1. #21
    Sencha User
    Join Date
    Sep 2008
    Posts
    193
    Vote Rating
    0
    fxmisticat is on a distinguished road

      0  

    Default


    Got it! Thanks again mystix!

  2. #22
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    961
    Vote Rating
    0
    Arno.Nyhm is on a distinguished road

      0  

    Thumbs up


    thx to mystix :-)

    here are my changes:

    - remove space between number and symbol so you can decide by yourself with the symbol parameter if you like to have a space
    - add parameter for position of symbol


    PHP Code:
    if (Ext.util.Format) {
        if (!
    Ext.util.Format.CurrencyFactory) {
            
    Ext.util.Format.CurrencyFactory = function(dpdSeparatortSeparatorsymbolrightPosition) {
                return function(
    n) {

                    
    dp Math.abs(dp) + dp 2;
                    
    dSeparator dSeparator || ".";
                    
    tSeparator tSeparator || ",";
                    
    symbol symbol || "$";
                    
    rightPosition rightPosition || false;

                    var 
    = /(\d+)(?:(\.\d+)|)/.exec(""),
                    
    m[1].length m[1].length 0;

                    var 
    = (0'-' ''// preserve minus sign
                    
    + (m[1].substr(0x) + tSeparator "")
                    + 
    m[1].substr(x).replace(/(\d{3})(?=\d)/g"$1" tSeparator)
                    + (
    dpdSeparator + (+m[2] || 0).toFixed(dp).substr(2) : "");

                    return 
    rightPosition?v+symbol:symbol+v;
                };
            };
        }

    usage:

    PHP Code:
    var eurFormatter Ext.util.Format.CurrencyFactory(2","".""\u20ac"true);
    var 
    value 12345.67;
    return 
    eurFormatter(value); //--> 12.345,67€

    var usFormatter Ext.util.Format.CurrencyFactory();
    var 
    value 12345.67;
    return 
    usFormatter(value); //--> $12,345.67 

  3. #23
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    961
    Vote Rating
    0
    Arno.Nyhm is on a distinguished road

      0  

    Default


    if you dont like to give the space into the symbol parameter then use this:

    PHP Code:
    if (Ext.util.Format) {
        if (!
    Ext.util.Format.CurrencyFactory) {
            
    Ext.Ext.util.Format.CurrencyFactory = function(hasSpacedpdSeparatortSeparatorsymbolrightPosition) {
                return function(
    n) {

                    var 
    spaceText hasSpace?" ":"";
                    
    dp Math.abs(dp) + dp 2;
                    
    dSeparator dSeparator || ".";
                    
    tSeparator tSeparator || ",";
                    
    symbol symbol || "$";
                    
    rightPosition rightPosition || false;

                    var 
    = /(\d+)(?:(\.\d+)|)/.exec(""),
                    
    m[1].length m[1].length 0;

                    var 
    = (0'-' ''// preserve minus sign
                    
    + (m[1].substr(0x) + tSeparator "")
                    + 
    m[1].substr(x).replace(/(\d{3})(?=\d)/g"$1" tSeparator)
                    + (
    dpdSeparator + (+m[2] || 0).toFixed(dp).substr(2) : "");

                    return 
    rightPosition?v+spaceText+symbol:symbol+spaceText+v;
                };
            };
        }

    usage:

    PHP Code:
    var eurFormatter Ext.util.Format.CurrencyFactory(false,2","".""\u20ac"true);
    var 
    value 12345.67;
    return 
    eurFormatter(value); //--> 12.345,67€

    var eurFormatter Ext.util.Format.CurrencyFactory(true,2","".""\u20ac"true);
    var 
    value 12345.67;
    return 
    eurFormatter(value); //--> 12.345,67 €

    var usFormatter Ext.util.Format.CurrencyFactory();
    var 
    value 12345.67;
    return 
    usFormatter(value); //--> $12,345.67

    var usFormatter Ext.util.Format.CurrencyFactory(true);
    var 
    value 12345.67;
    return 
    usFormatter(value); //--> $ 12,345.67 

  4. #24
    Sencha User sosy's Avatar
    Join Date
    Jun 2010
    Location
    Bremen, but Dutch origin
    Posts
    64
    Vote Rating
    0
    sosy is on a distinguished road

      0  

    Default


    Maybe a bit older thread, but it was usefull for me!

    Pimped it a bit to use it in an EditorGrid, so that you can type in values with commata, then transform it to Euro value, or if there is no value an - to keep the grid much cleaner to look ad.

    Code:
    //
    // EURO
    //
    Ext.util.Format.Currency = function(v)
    {
         v = Ext.num(String(v).replace(/\,/, '.'));
         v = (Math.round((v-0)*100))/100;
         v = (v == Math.floor(v)) ? v + ".00" : ((v*10 == Math.floor(v*10)) ? v + "0" : v);
         if (v==0)
         {
               v = '-';
               return (v);
         }
         else
         {
               return (v + ' €').replace(/\./, ',');
          }
    };
    Hope it is usefull for some of you..

    Regards

    Sosy
    I prefer an sister in the red-light district, to an brother with internet explorer..

  5. #25
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,137
    Vote Rating
    321
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    Thank you for sharing.

  6. #26
    Ext User
    Join Date
    Oct 2010
    Posts
    1
    Vote Rating
    0
    yassyboy is on a distinguished road

      0  

    Default


    Hi All,

    I am beginner in ExtJS so bear my newbie Questions.

    Where do I place the custom currency render-er? In the beginning of the code? Any examples will be higher appreciated.

    Eg. "replaceParameter.push({oldStr:"{{totalPaidAmount}}", newStr:Ext.util.Format.usMoney(totalPaidAmount)}); "

    If I want to put "gbMoney" how do I do it .. in a very layman terms.

    Thank you

    Kind Regards

    Yassyboy

  7. #27
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    Code:
    Ext.util.Format.gbMoney = function(value){
      return ...
    };

  8. #28
    Sencha User
    Join Date
    Oct 2008
    Posts
    81
    Vote Rating
    0
    Pachat is on a distinguished road

      0  

    Default


    If you want to emphasize on usMoney, here is an example for Euro :
    Code:
    Euro = function(v)
    {
        v = Ext.util.Format.usMoney(v);
        if (v=='$0.00')
            return '-';
        else
            return v.replace(/\$/, '').replace(/\,/g, ' ').replace(/\./, ',')+' &euro';
    };

  9. #29
    Sencha User citstudio's Avatar
    Join Date
    Oct 2011
    Location
    Indonesia
    Posts
    1
    Vote Rating
    0
    citstudio is on a distinguished road

      0  

    Wink this is for other currency's format

    this is for other currency's format


    I've made some modification from original form (usMoney) function
    this is for japan currency (yen = ¥)

    Code:
    Ext.util.Format.jpyMoney = function(v) { // override Ext.util.usMoney
            v = Ext.num(v, 0); // ensure v is a valid numeric value, otherwise use 0 as a base (fixes $NaN.00 appearing in summaryRow when no records exist)
            v = (Math.round((v - 0) * 100)) / 100;
            v = (v == Math.floor(v)) ? v + "" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v);
            v = String(v);
            var ps = v.split('.');
            var whole = ps[0];
            var sub = ps[1] ? '.'+ ps[1] : '';
            var r = /(\d+)(\d{3})/;
            while (r.test(whole)) {
                whole = whole.replace(r, '$1' + ',' + '$2');
            }
            v = whole + sub;
            if (v.charAt(0) == '-') {
                    return '-¥ ' + v.substr(1);
            }
            return "¥ " + v;
    }
    here it's for other currency's symbols :
    http://www.hypergurl.com/asciisymbols.html
    Last edited by citstudio; 30 Oct 2011 at 11:28 PM. Reason: adding phrase

  10. #30
    Sencha User
    Join Date
    Jul 2007
    Posts
    1
    Vote Rating
    0
    tolisc is on a distinguished road

      0  

    Default


    PHP Code:
    Ext.util.Format.euroCurrency = function(v){
        return 
    Ext.util.Format.currency(v'€'2);        
    };

    and 
    in your app launch 
    launch
    : function() {
            if (
    Ext.util.Format) {
                
    Ext.apply(Ext.util.Format, {
                    
    thousandSeparator '.',
                    
    decimalSeparator  ','
                
    });
            };       


film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar