derphil
derphil

Reputation: 385

Thousands separators in Ext.form.NumberField

I want to override some config options of Ext.form.NumberField, but I don't find something like a "thousands separator". Is there a way to define this for NumberFields in Ext?

Or have I had to write my own function to provide this functionality?

Upvotes: 1

Views: 6811

Answers (2)

Omid Shariati
Omid Shariati

Reputation: 1916

you can also use this override

Ext.override.ThousandSeparatorNumberField

Upvotes: 2

dougajmcdonald
dougajmcdonald

Reputation: 20047

On closer inspection according to the forums/devs, NumberField doesn't support formatting. Numbercolumn on a grid does.

Their suggestion is to use a TextField and either format the value serverside before displaying it, or to apply a function on say, the 'change' event of a text field to apply the formatting you want, e.g.

        <ext:TextField             
            ID="txtField"            
            runat="server"             
            FieldLabel="My Label"            
            AllowBlank="false"             
            ReadOnly="true">             
            <Listeners>                 
                <Change Handler="this.setValue(Ext.util.Format.number(newValue.replace(/[\,\.]/g, ''), '0.000/i'));" />             
            </Listeners>         
        </ext:TextField>

I would assume you'd need to tweak things a little to ensure your value was displayed as you'd like but there should be something you fit in the Ext.util.Format.number patterns listed here:

http://dev.sencha.com/deploy/ext-3.3.1/docs/output/Ext.util.Format.html#Ext.util.Format-number

Upvotes: 1

Related Questions