开发者

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 Num开发者_Python百科berFields in Ext?

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


you can also use this override

Ext.override.ThousandSeparatorNumberField


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜