日期:2014-05-16  浏览次数:20342 次

Extjs拓展显示文本控件
Ext.StaticTextField = Ext.extend(Ext.form.Field,{
	defaultAutoCreate:{tag:"div"},
	field:null,
	value:'--',
	onRender:function(ct,position){
		Ext.StaticTextField.superclass.onRender.call(this,ct,position);
		Ext.DomHelper.append(this.el,{
			tag:'div',
			style:'height:100%;width:100%;',
			html:"<span style='FONT-SIZE: 12pt; FONT-FAMILY:system;color:blue' >"+this.getValue()+"</span>"
		});
	},
	getValue:function(){
		if(!this.rendered) {
            return this.value;
        }
        try {
        	var v = this.el.getValue();
        	if(v === this.emptyText || v === undefined){
            	v = '';
        	}
        }catch(ex){
        	alert("get value error of "+this.name);
        }
        
        return v;
	},
	setValue:function(v){
		this.value = v;
        if(this.rendered){
            this.el.dom.value = (v === null || v === undefined ? '' : v);
            this.validate();
            Ext.DomHelper.overwrite(this.el,{
			tag:'div',
			style:'height:100%;width:100%;',
			html:"<span style='FONT-SIZE: 12pt; FONT-FAMILY:system;color:blue' >"+this.value+"</span>"
			});
        }
	}
});
Ext.reg('StaticTextField',Ext.StaticTextField);