View Full Version : Number field currency format format problem

2 Sep 2011, 12:07 AM
Hi all,
I'm using numberfield on my accounting project. But i couldnt correct number fields format on my project. For example if number is 1,01 its showing normal. But if number is 1,00 just showing number 1 but should to show 1,00 . I couldnt adjust with ext.js. I investigate on this form found some example tried but didnt work. If somebody has exact answer please share with.


3 Sep 2011, 1:17 PM
Here's something that might work. You may need to tweak it to get the locale working the way you want. The usual warnings about not using floating point numbers to represent monetary values apply.

Ext.define('CurrencyField', {
extend: 'Ext.form.field.Number',

// Some sensible defaults
allowDecimals: true,
hideTrigger: true,
keyNavEnabled: false,
mouseWheelEnabled: false,

valueToRaw: function() {
var value = this.parseValue(this.callParent(arguments));

return Ext.util.Format.number(value, '0.00');

Ext.create('CurrencyField', {
renderTo: Ext.getBody()

12 Sep 2011, 10:54 PM
Hi skirtle ,
Thank you very much for your answer. I investigate very much about that problem and finally i decided(learned) to override my numberfield. That following codes showing how to override number field. Its working nl and Gb culture formats it has dynamic group and decimal seperators. so doesnt matter which culture u are using its working correct.
Everyone can try if they are using money calculations in their projects.