首页 新闻 会员 周边

ExtJs4.2.1如何给NumberField用unitText加单位?

0
悬赏园豆:5 [待解决问题]

在网上搜的说是用这个方法,但是不好使,求大神帮忙

Ext.override(Ext.form.TextField, {
unitText: '',
onRender: function (ct, position) {
Ext.form.TextField.superclass.onRender.call(this, ct, position);
// 如果单位字符串已定义 则在后方增加单位对象
if (this.unitText != '') {
this.unitEl = ct.createChild({
tag: 'div',
html: this.unitText
});
this.unitEl.addClass('x-form-unit');
// 增加单位名称的同时 按单位名称大小减少文本框的长度 初步考虑了中英文混排 未考虑为负的情况
this.width = this.width - (this.unitText.replace(/[^\x00-\xff]/g, "xx").length * 6 + 2);
// 同时修改错误提示图标的位置
this.alignErrorIcon = function () {
this.errorIcon.alignTo(this.unitEl, 'tl-tr', [2, 0]);
};
}
}
});

骑着乌龟漫步的主页 骑着乌龟漫步 | 菜鸟二级 | 园豆:206
提问于:2015-05-05 19:16
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册