PDA

View Full Version : display decimals in a numberfield



nawin.muttineni@gmail.com
31 Oct 2012, 11:04 PM
I would like to display expenseAmount as xxx.00
i have tried with renderer but it is not working
my code is bellow , any suggestions please....


{
xtype:'numberfield',
fieldLabel: 'expenseAmount',
name: 'expenseAmount',
allowBlank:false,
tabIndex:13,
fieldCls :'cNumAlign',
// renderer : Ext.util.Format.numberRenderer('0.00'),
decimalPrecision: 2,
renderer: Ext.util.Format.usMoney,
listeners: {
change: function() {
me.setTotalExpenseAmount();
}
}
}

sword-it
1 Nov 2012, 3:17 AM
Hi Naveen,

You can achieve the above format by javascript toFixed(2) method, like-



xtype: 'numberfield',
anchor: '100%',
name: 'bottles',
fieldLabel: 'Bottles of Beer',
decimalPrecision:3,
value: 99,
maxValue: 99,
minValue: 0,
listeners:{
blur:function(){
var value = this.getValue()
newValue = value.toFixed(2);
this.setRawValue(newValue);
}
}