Extjs.form.TextField的默認(rèn)在輸入框后面是不能加入文字。在網(wǎng)上找到此方法以備查用。
在頁(yè)面中引入此段js代碼
Ext.override(Ext.form.TextField, {
unitText : '',
on
Render : function(ct, position) {
Ext.form.TextField.superclass.onRender.call(this, ct, position);
// 如果單位字符串已定義 則在后方增加單位對(duì)象
if (this.unitText != '') {
this.unitEl = ct.createChild({
tag : 'div',
html : this.unitText
});
this.unitEl.addClass('x-form-unit');
// 增加單位名稱(chēng)的同時(shí) 按單位名稱(chēng)大小減少文本框的長(zhǎng)度 初步考慮了中英文混排 未考慮為負(fù)的情況
this.width = this.width - (this.unitText.replace(/[^\x00-\xff]/g, "xx").length * 6 + 2);
// 同時(shí)修改錯(cuò)誤提示圖標(biāo)的位置
this.alignErrorIcon = function() {
this.errorIcon.alignTo(this.unitEl, 'tl-tr', [2, 0]);
};
}
}
})
再加入些樣式
<style>
.x-form-unit {
height: 22px;
line-height: 22px;
padding-left: 2px;
display: inline-block;
display: inline;
}
</style>
posted on 2011-07-14 11:28
王豪 閱讀(559)
評(píng)論(0) 編輯 收藏 所屬分類(lèi):
EXT 筆記