Ext.form.NumberField中的数千个分隔符 [英] Thousands separators in Ext.form.NumberField
问题描述
我想覆盖Ext.form.NumberField的一些配置选项,但是我没有找到像数千分隔符这样的东西。有没有办法为Ext中的NumberField定义这个?
或者我必须编写自己的函数来提供这个功能?
根据forums / devs进行仔细检查,NumberField不支持格式化。他们的建议是使用TextField,并在显示之前格式化服务器端,或者应用一个功能,即更改文本字段的事件应用您想要的格式,例如
< ext:TextField
ID =txtField
runat =server
FieldLabel =我的标签
AllowBlank =false
ReadOnly =true>
< Listeners>
< Change Handler =this.setValue(Ext.util.Format.number(newValue.replace(/ [\,\。] / g,''),'0.000 / i')); />
< / Listeners>
< / ext:TextField>
我会假设你需要调整一些事情,以确保你的价值显示为你' d喜欢,但应该有一些你适合在这里列出的Ext.util.Format.number模式:
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?
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
这篇关于Ext.form.NumberField中的数千个分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!