0

如何格式化 itemTpl 中的数字?

例子:

'<div style="font-size: 9px;">Total: $ {total}</div>' <= This number {total} must be 100.00, but appears just 100

谢谢!

4

2 回答 2

0

使用您的成员函数XTemplate

itemTpl: new Ext.XTemplate(
    '<div style="font-size: 9px;">Total: $ {[this.formatTotal(values.total)]}</div>',
    formatTotal: function(total) {
        return //formattedTotal
    }
)

在此处了解更多信息:http ://docs.sencha.com/touch/2.2.1/#!/api/Ext.XTemplate

于 2013-08-21T13:39:37.810 回答
0

正如@kevhender 所说,您可以使用Ext.XTemplatetoFixed javascript 方法进行格式化。

更详细

itemTpl: new Ext.XTemplate(
     '<div style="font-size: 9px;">Total: $ {[this.totalFormat(values.total)]}</div>',{
        totalFormat : function(total) {
          return total.toFixed(2);
      }
})
于 2013-08-21T16:00:12.553 回答