
Gfa.form.QuickSearchField = function(config){
    Gfa.form.QuickSearchField.superclass.constructor.call(this, config);
    if(config.isGrid != undefined){
    	 this.isGrid  = config.isGrid ;
    }
    this.addEvents({
		"afterSelect" : true
	});
	this.on("afterSelect", this.fillEntity, this);
	this.on('focus',this.tFocus,this);
	this.on('blur',this.lookForEntity,this);
};
Ext.extend(Gfa.form.QuickSearchField, Ext.form.TriggerField, {
	times:0,
	temp:undefined,
	displayField: undefined,
	oldEntity: undefined,
	quickSearchDlg : undefined,
	parameters : undefined,
	isGrid:true,
	triggerClass : 'x-form-search-trigger',
	selected : false,
	upperCase : false,    // <自定义> 是否自动转成大写字母
	listeners : {
		'specialkey' : function(obj, e){ 
			if (e.getKey() == e.TAB) { 
				if (this.upperCase){
					this.setValue(this.getValue().toUpperCase());   //转化为大写
				}
			} 
		},
		/*'blur': function(){
			//this.setValue(this.getValue().toUpperCase()); //转化为大写
		},*/
		'focus': function(filed){
			filed.selectText();
		}
	},
	
	onTriggerClick : function(){	
	    this.dialogInit();
	    this.quickSearchDlg.reset();
		this.quickSearchDlg.showDlg();
		this.quickSearchDlg.setInitValue(this.displayField,this.getValue());
		this.quickSearchDlg.load();
    },
    
    dialogInit:function(){
    	if(!this.quickSearchDlg){
    		this.quickSearchDlg = new Gfa.form.QuickSearch({
    		parameters:this.parameters,
    		cm:this.cm,
    		ds:this.ds,
    		QuickField:this
    		}); 
    	}
    },
    
    fillEntity : function(qsentity){
    	this.oldEntity = qsentity;
    	this.entity =  qsentity;
    	this.setValue(qsentity[this.displayField]);
    	Ext.form.TriggerField.superclass.onBlur.call(this);   
    },
    
    getValue : function(){
    	return Gfa.form.QuickSearchField.superclass.getValue.call(this).toUpperCase();},
    
    triggerBlur : function(){},
	
	tFocus : function(){},
	
	lookForEntity:function(){
		if(this.getValue instanceof Object){
		    this.setValue(this.getValue().toUpperCase()) ;
			return 
		}
		if(this.isGrid){
	    	
	    	 return
		}
	}
});
Ext.reg('gfaquicksearchfield', Gfa.form.QuickSearchField);
