UnitText.js
=======================
// 輸入框textfield後面放字unitText定義:
Ext.override(Ext.form.TextField, {
unitText : '',
onRender : function(ct, position) {
Ext.form.TextField.superclass.onRender.call(this,ct, position);
if (this.unitText != '');
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.alignTorrorIcon= function() {
this.errorIcon.alignTo (this.unitEl,'tl-tr', [2, 0]); }});
將UnitText.js放入jsp檔案中,加上css樣式,如下: 複製程式碼
程式碼如下:
display:inline;
程式碼如下:
var jine = new Ext.form.NumberField({
id: 'je',
fieldLabel : '金額',
allowDecimals: true, // 允許小數點?
allowNegative: false, // 允許負數?
width: 100,
style: 'text-align:right',
unitText: ' 元' });