-
18 Oct 2012 8:34 AM #1
How to use Ext.field.Number with locale formatted numbers?
How to use Ext.field.Number with locale formatted numbers?
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 #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,675
- Vote Rating
- 435
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
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
22 Oct 2012 12:01 PM #3
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:
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.Code: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(); } });
How can I update the UI to display the new value that was set?
Thank you.
-
24 Oct 2012 1:44 AM #4
[Close]
[Close]
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.


Reply With Quote