Overriding/Extending Ext.util.Format

  • I would like to override the Ext.util.Format class adding some of my application's own formatting methods.

    I have tried the following but it breaks when using the Ext.Template class

    Ext.override(Ext.util.Format, {

    ukMoney : 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('.');
    var whole = ps[0];
    var sub = ps[1] ? '.'+ ps[1] : '.00';
    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;
    }
    });
    I want to be able to use the following in my column models. renderer: Ext.util.Format.ukMoney and the following in my templates. {template_var:ukMoney}

    The error returned in firebug is:
    p is undefined
    chrome://firebug/content/blank.gifExt={version:"2.1"};window["undefined"]=...new Date()).getTime()-this.getTime())};


  • Or you could use this (http://extjs.com/forum/showthread.php?t=48600).


  • It's a singleton, not a class. An Object. You cannot override methods of an object.

    You can set properties in it....







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Overriding/Extending Ext.util.Format , Please add it free.

    16 March 2010 | cameltoepants.com | edit