Extjs.form.TextField的默認在輸入框后面是不能加入文字。在網上找到此方法以備查用。
在頁面中引入此段js代碼
Ext.override(Ext.form.TextField, {
unitText : '',
on
Render : 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]);
};
}
}
})
再加入些樣式
<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)
評論(0) 編輯 收藏 所屬分類:
EXT 筆記