Thousands separators in Ext.form.NumberField

ぐ巨炮叔叔 提交于 2019-12-11 10:24:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!