extjs combobox分页加载数据不显示

在加一个事件之前是对的可以加载,但是在添加一个事件之后,不可显示了,以下是错误的代码

/**
 * YHC
 */

/**
 * 分页的Combobox
 */
PagingMedicalcareCbo=Ext.extend(Ext.form.ComboBox,{
	/**
	 * 构造方法
	 */
	timedelay_Slow:2000,//1000ms=1s
	timedelay_fast:1000,//1000ms=1s
	form:null,
	t:null,
	onceFocus:false,//判断第一次获得焦点
	width:180,
	myStore:null,
	currentCboText:null,//当前CBO文本框中的值
	constructor:function(conf){
		//宽度赋值
		this.width=(conf.width!='undefined')? conf.width : this.width;
		this.myStore=new Ext.data.JsonStore({
			url:"/his/medical_care!ajaxMedicalcareCbo.action",//url地址
			root: 'root',
			idProperty: 'linkId',
			totalProperty:"totalProperty", 
			fields:[{name:"linkId"},
					{name:"orgCode"},
				    {name:"orgName"},
					{name:"dbName"},
					{name:"serverType"}],
			listeners :{
				beforeload:this.onCboBeforeLoad,
				scope:this
			}
		});
		

		//
		PagingMedicalcareCbo.superclass.constructor.call(this,{
			id:"searchCbo",
			name:'searchCbo',
			store:this.myStore,
			mode:"remote",
			pageSize:5,
			triggerAction:"all",
			displayField:"orgName",
			//valueField:"linkId",
			width:this.width,
			listWidth:220,
			fieldLabel:'医疗单位',
			value:'输入可搜索(new)',
			listeners :{
				select:this.onSelected,
				keyup:this.onKeyup,
				focus:this.onFocus,
				scope:this
				}
		});
		
	},
	//设置参数
	onCboBeforeLoad:function(store,options){
		if(this.currentCboText!=null&&(typeof this.currentCboText)!='undefined'){
			//带机构名称
			store.baseParams={'medicalCareVo.orgName':this.currentCboText};	
		}else{
			//没有任何的参数
			store.baseParams={};
		}
		
	},
	//选择之后,对应赋值
	onSelected:function(combo,record,index){
		var orgName=this.myStore.getAt(index).get('orgName');
		//this.value=orgName;
		//alert(this.myStore.getAt(index).get('orgName'));
		//alert(record.get('orgName'));
		this.form.findField('orgCode').setValue(record.get('orgCode'));
		this.form.findField('linkId').setValue(record.get('linkId'));
		this.form.findField('dbName').setValue(record.get('dbName'));
		this.form.findField('serverType').setValue(record.get('serverType'));
	},
	//键盘弹起的时候 ,赋值当前文本值
	onKeyup:function(combo,e){
		this.currentCboText=Ext.getCmp('searchCbo').getValue();
		//切记 清除(很重要) 下一次需要清除上一次
		if(this.t){
			window.clearInterval(this.t);//清除延时执行
		}
		//如果此时用户将文本框的值删除完之后(也就是没有任何的值)
        if(this.currentCboText==''){
        this.t=window.setInterval('Ext.getCmp("searchCbo").myStoreLoadData()', this.timedelay_fast);
        return;
        }
		//延时执行,避免用户输入太快,导致访问服务器次数增加,节约性能
		this.t=window.setInterval('Ext.getCmp("searchCbo").myStoreLoadData()', this.timedelay_Slow);
		
	},
	//--myStore重新加载数据
	myStoreLoadData:function(){
		
		//重新加载数据
        this.myStore.load({
        	params:{start:0,limit:5}
    	});
        //切记 清除(很重要)
		if(this.t!=null){
			window.clearInterval(this.t);//清除延时执行
		}
	},
	//--设置Form对象的方法
	setForm:function(form){
		this.form=form;
	},
	//--第一次获得焦点的时候
	  onFocus:function(combo){
		
		if(!this.hasOnceFocus){
			this.onceFocus=true;
			this.setValue('');//判断是否是第一次
		}
	}
});

经改正后的代码,事件的名字onFocus更换,还有变量名onceFocus更换就OK 了

命名有冲突:

正确代码:

/**
 * YHC
 */

/**
 * 分页的Combobox
 */
PagingMedicalcareCbo=Ext.extend(Ext.form.ComboBox,{
	/**
	 * 构造方法
	 */
	timedelay_Slow:2000,//1000ms=1s
	timedelay_fast:1000,//1000ms=1s
	form:null,
	t:null,
	hasOnceFocus:false,//判断第一次获得焦点
	width:180,
	myStore:null,
	currentCboText:null,//当前CBO文本框中的值
	constructor:function(conf){
		//宽度赋值
		this.width=(conf.width!='undefined')? conf.width : this.width;
		this.myStore=new Ext.data.JsonStore({
			url:"/his/medical_care!ajaxMedicalcareCbo.action",//url地址
			root: 'root',
			idProperty: 'linkId',
			totalProperty:"totalProperty", 
			fields:[{name:"linkId"},
					{name:"orgCode"},
				    {name:"orgName"},
					{name:"dbName"},
					{name:"serverType"}],
			listeners :{
				beforeload:this.onCboBeforeLoad,
				scope:this
			}
		});
		

		//
		PagingMedicalcareCbo.superclass.constructor.call(this,{
			id:"searchCbo",
			name:'searchCbo',
			store:this.myStore,
			mode:"remote",
			pageSize:5,
			triggerAction:"all",
			displayField:"orgName",
			//valueField:"linkId",
			width:this.width,
			listWidth:220,
			fieldLabel:'医疗单位',
			value:'输入可搜索(new)',
			listeners :{
				select:this.onSelected,
				keyup:this.onKeyup,
				focus:this.onPromptFocus,
				scope:this
				}
		});
		
	},
	//设置参数
	onCboBeforeLoad:function(store,options){
		if(this.currentCboText!=null&&(typeof this.currentCboText)!='undefined'){
			//带机构名称
			store.baseParams={'medicalCareVo.orgName':this.currentCboText};	
		}else{
			//没有任何的参数
			store.baseParams={};
		}
		
	},
	//选择之后,对应赋值
	onSelected:function(combo,record,index){
		var orgName=this.myStore.getAt(index).get('orgName');
		//this.value=orgName;
		//alert(this.myStore.getAt(index).get('orgName'));
		//alert(record.get('orgName'));
		this.form.findField('orgCode').setValue(record.get('orgCode'));
		this.form.findField('linkId').setValue(record.get('linkId'));
		this.form.findField('dbName').setValue(record.get('dbName'));
		this.form.findField('serverType').setValue(record.get('serverType'));
	},
	//键盘弹起的时候 ,赋值当前文本值
	onKeyup:function(combo,e){
		this.currentCboText=Ext.getCmp('searchCbo').getValue();
		//切记 清除(很重要) 下一次需要清除上一次
		if(this.t){
			window.clearInterval(this.t);//清除延时执行
		}
		//如果此时用户将文本框的值删除完之后(也就是没有任何的值)
        if(this.currentCboText==''){
        this.t=window.setInterval('Ext.getCmp("searchCbo").myStoreLoadData()', this.timedelay_fast);
        return;
        }
		//延时执行,避免用户输入太快,导致访问服务器次数增加,节约性能
		this.t=window.setInterval('Ext.getCmp("searchCbo").myStoreLoadData()', this.timedelay_Slow);
		
	},
	//--myStore重新加载数据
	myStoreLoadData:function(){
		
		//重新加载数据
        this.myStore.load({
        	params:{start:0,limit:5}
    	});
        //切记 清除(很重要)
		if(this.t!=null){
			window.clearInterval(this.t);//清除延时执行
		}
	},
	//--设置Form对象的方法
	setForm:function(form){
		this.form=form;
	},
	//--第一次获得焦点的时候
	  onPromptFocus:function(combo){
		
		if(!this.hasOnceFocus){
			this.hasOnceFocus=true;
			this.setValue('');//判断是否是第一次
		}
	}
});



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值