1. #1
    Sencha User
    Join Date
    Jun 2010
    Posts
    49
    Vote Rating
    0
    luisoswaldo is on a distinguished road

      0  

    Default Euro or other currency value to format

    Euro or other currency value to format


    Such thing as util.format.usMoney to format the currency the euro or other currency. I was trying to duplicate the function to suit my needs, but I could not do it.

    This is the code of the function

    Code:
    usMoney : function(v) {           
     v = (Math.round((v-0)*100))/100;          
    v = (v == Math.floor(v)) ? v + ".00" : ((v*10 == Math.floor(v*10)) ? v + "0" : v);           
     v = String(v);           
    var ps = v.split('.'),                
    whole = ps[0],               
     sub = ps[1] ? '.'+ ps[1] : '.00',               
     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;        },
    I appreciate any help i can offer.

  2. #2
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default I didnt understand

    I didnt understand


    Hi,

    I didnt understand what you need.. Do you want override Ext.util.Format.usMoney function ? And what are your needs ?
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  3. #3
    Sencha User
    Join Date
    Jun 2010
    Posts
    49
    Vote Rating
    0
    luisoswaldo is on a distinguished road

      0  

    Default


    Yes, i need override usMoney or add others currencys in the same function.

  4. #4
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default Ext.override

    Ext.override


    Hi,
    you can use Ext.override. Please see below code:
    Code:
    Ext.override(Ext.util.Format, {
        usMoney : function(v, sign, end) {
            v = (Math.round((v-0)*100))/100;
            v = (v == Math.floor(v)) ? v + ".00" : ((v*10 == Math.floor(v*10)) ? v + "0" : v);
            v = String(v);
            var ps = v.split('.'),
                whole = ps[0],
                sub = ps[1] ? '.'+ ps[1] : '.00',
                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);
            }
            if(end) {
                return v + sign;
            }
            else {
                return sign +  v;
            }    
        }
    })
    Example:
    Code:
    Ext.util.Format.usMoney('12','TL',true)
    //returns "12.00TL"
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  5. #5
    Sencha User
    Join Date
    Jun 2010
    Posts
    49
    Vote Rating
    0
    luisoswaldo is on a distinguished road

      0  

    Default


    I could not do that overrides the method usMoney. Where should I place that code?

    The place where I have a js function, then the onReady and then within InitComponent and not work.

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi