ExtJS 数字格式。小数点后3位

标签 extjs

使用 ExtJS4.1,我有浮点作为 JSON 响应。如何将浮点值格式化为小数点后 3 位数字。在示例下方找到。请帮忙。

enter code here

Example:

{ 
header: 'Total', 
sortable: true, 
dataIndex: 'total', 
field: { xtype: 'numberfield' }, 
renderer: this.onRenderCell 
}

onRenderCell : function(value, metaData, record, rowIndex,colIndex, store, view){
   Ext.util.Format.numberRenderer(value,'0.000');
   return value;            
}
------------------------------------------------------------------------

最佳答案

您可以使用 number(v, format) 函数,例如:

Ext.util.Format.number(1.23456, '0.000');

女巫会回来:

"1.235"



(您尝试过的 numberRenderer 女巫返回一个函数)

关于ExtJS 数字格式。小数点后3位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13374697/

相关文章:

javascript - HTML内容显示有限行

javascript - 高级选项卡面板向导

javascript - 如何用 Siesta 覆盖 testClass 方法?

extjs - 如何在TabPanel中显示Ext.List数据?

javascript - Sencha Touch 2,来自远程代理的每个存储负载的 CPU 使用率增加

javascript - Sencha Touch 日期代码在 Chrome 中运行良好,但在 Safari 中失败

javascript - ExtJs4 网格不显示响应中的数据

css - ExtJS - 如何让 addCls() 和 removeCls() 显示更改

javascript - extjs 组合框

extjs - 在 Sencha Touch 中访问静态属性