PDA

View Full Version : Exponential Notation



floraoma2000-extjs
16 May 2013, 12:17 AM
Hi,
I have a simple numberfield

{
xtype: 'numberfield'
fieldLabel: 'Input Number ',
name: 'number',
baseChars:'1234567890.E'
}

The input is a number in exponential notation - sth like this 1.2E10
The numberfield is automatically formatted to 12000000000.
How can I suppress this formatting?
Thanks

tobiu
16 May 2013, 8:07 AM
the numberfield was not designed to display exponential values, it is using parseFloat() internally:


valueToRaw: function(value) {
var me = this,
decimalSeparator = me.decimalSeparator;
value = me.parseValue(value);
value = me.fixPrecision(value);
value = Ext.isNumber(value) ? value : parseFloat(String(value).replace(decimalSeparator, '.'));
value = isNaN(value) ? '' : String(value).replace('.', decimalSeparator);
return value;
}


you could customize this class. imho the easier way to go is using a textfield and apply a regex for the validation:
http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.form.field.Text-cfg-regex