Extjs 디스플레이 텍스트 컨트롤 확장

1552 단어 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);

좋은 웹페이지 즐겨찾기