EXTJS网格中的小数精度 [英] Decimal precision in an EXTJS grid
本文介绍了EXTJS网格中的小数精度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个网格,让用户通过编辑行来输入数字。我希望数字支持4位小数,但它只支持2.我计算出如何显示4位小数,但它没有注册超过2位小数的位置。
因此,如果用户输入1000.1111,则结果字段将在网格中显示1000.1100。
模型中的字段如下所示:
$ b我怎样才能告诉模型该字段精确到小数点后4位? $ b
{name:'Price_Customer__c',type:'number'},
网格中的列设置为这样:
{
header:' Price to Customer',
flex:0,
width:100,
sortable:true,
renderer:Ext.util.Format.numberRenderer('$ 0,000.0000'),
dataIndex:'Price_Customer__c',
summaryType:'sum',
field:{
xtype:'numberfield'
}
},
解决方案
{
header:'Price to Customer',
flex:0,
width:100,
sortable:true,
渲染器:Ext.util.Format.numberRend erer('$ 0,000.0000'),
dataIndex:'Price_Customer__c',
summaryType:'sum',
编辑器:{//字段从4.0.5开始已弃用
xtype :'numberfield',
decimalPrecision:4
}
}
I have a grid which lets a user enter in a number by editing the row. I want the number to support 4 decimal places, but it only supports 2. I figured out how to display 4 decimal places but it doesn't register anything more than 2 decimal places.
So if the user enters 1000.1111 the resulting field will show 1000.1100 in the grid. How can I tell the model that the field is precise to 4 decimal places?
My field in the model looks like this:
{name: 'Price_Customer__c', type: 'number'},
The column in the grid is set up like this:
{
header: 'Price to Customer',
flex: 0,
width: 100,
sortable: true,
renderer: Ext.util.Format.numberRenderer('$0,000.0000'),
dataIndex: 'Price_Customer__c',
summaryType: 'sum',
field: {
xtype: 'numberfield'
}
},
解决方案
This should work:
{
header: 'Price to Customer',
flex: 0,
width: 100,
sortable: true,
renderer: Ext.util.Format.numberRenderer('$0,000.0000'),
dataIndex: 'Price_Customer__c',
summaryType: 'sum',
editor: { //field has been deprecated as of 4.0.5
xtype: 'numberfield',
decimalPrecision: 4
}
}
这篇关于EXTJS网格中的小数精度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文