View Full Version : How to use Ext.field.Number with locale formatted numbers?

18 Oct 2012, 8:34 AM
Hi I have several Ext.field.Number inputs and I want to display the numbers using the locale configuration. I.e : 1000.00 should be displayed as 1,000.00.

How can I change the formatting of the number displayed in the number field?

I am using Sencha Touch 2

Thank you.

20 Oct 2012, 8:27 AM
You would have to use a text field if you want to change the format that is displayed otherwise it's up to the device to format the number

22 Oct 2012, 12:01 PM
Thanks Mitchell,

I have given a shot the text field, but I am stuck again. I am just probably missing something obvious.

I have try to create my own input field type as:

Ext.define('Ext.field.FormattedNumber', {
extend: 'Ext.field.Text',
xtype: 'formattednumberfield',
alternateClassName: 'Ext.form.FormattedNumber',

config: {
component: { type: 'text' },
ui: 'text',

applyValue: function(newValue) {
var component = this.getComponent();
newValue = parseFloat(newValue);
return (isNaN(newValue)) ? 0 : newValue.toLocaleString();

This set up the value of this._value correctly and when the input field is instantiate the field content is displayed properly, but when I introduce a new value a hit enter this._value is update it accordingly, but the html element in the ui still is not update. I.e. if I introduce the character a this.value is set to 0 but in the application I still see the 'a' charater instead of been replace with a 0.

How can I update the UI to display the new value that was set?

Thank you.

24 Oct 2012, 1:44 AM
I find out how I create a formatNumber method that I am calling in the onchange event. not the nicest way but it makes the trick.