Ext gridPanel ColumnModel中钱的格式设置

来源:互联网 发布:亲哥借身份证开淘宝店 编辑:程序博客网 时间:2024/05/22 04:54
{header : "金额",
        width:100,
        dataIndex : 'amount',
        renderer: amountFormat
},
/**金额格式*/
    function amountFormat(v){
            v = (Math.round((v*100-0)*1))/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;
  }
----------------------------------------------------------------------
Ext gridPanel ColumnModel中钱的格式设置 - 浮水弹心 - zhao.xuepu

如果去掉注释的三行,负数的金额会前面加$符号。
0 0
原创粉丝点击