问题
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?
回答1:
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
回答2:
you can also use this override
Ext.override.ThousandSeparatorNumberField
来源:https://stackoverflow.com/questions/7413188/thousands-separators-in-ext-form-numberfield