1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    3
    Vote Rating
    0
    pdelgallego is on a distinguished road

      0  

    Default 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.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,704
    Vote Rating
    751
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Oct 2012
    Posts
    3
    Vote Rating
    0
    pdelgallego is on a distinguished road

      0  

    Default


    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:

    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();
      }
    });
    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.

  4. #4
    Sencha User
    Join Date
    Oct 2012
    Posts
    3
    Vote Rating
    0
    pdelgallego is on a distinguished road

      0  

    Default [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.

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar