`
isiqi
  • 浏览: 16035092 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

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('');//判断是否是第一次
		}
	}
});



分享到:
评论

相关推荐

    深入浅出Extjs4.1.1

    不多说,如果你需要学习Extjs或者是不懂Extjs,这门视频能对你有很大的帮助,文件过大,上传乃是下载链接,下面上目录: 1、ExtJs初识及其环境搭建 2、开始ExtJs梦想之旅# n8 }: ~+ d4 X+ V1 c 3、ExtJS工具栏、菜单...

    ExtJS4中文教程2 开发笔记 chm

    Extjs4.0动态填充combobox数据 Extjs4中up()和down()的用法 ExtJS4学习笔记(一)---window的创建 ExtJS4学习笔记(七)---带搜索的Grid(SearchGrid) ExtJS4学习笔记(三)---VBox的使用 ExtJS4学习笔记(九)---ExtJS4 ...

    轻松搞定Extjs_原创

    第十章:数据与ComboBox 57 一、数据在这里是动词 57 二、Ext.data.DataProxy类 57 三、Ext.data.DataReader类 58 四、Ext.data.Store类 59 五、下拉列表框 60 六、得到下拉列表框的值 62 七、源代码 63 八、小结 64...

    Ext Js权威指南(.zip.001

    7.5.5 ext.data.treestore加载数据的方法 / 354 7.5.6 store的配置项 / 358 7.5.7 store的分页 / 359 7.5.8 store的排序:ext.util.sorter与ext.util.sortable / 360 7.5.9 store的过滤:ext.util.filter / 363...

    EXT教程EXT用大量的实例演示Ext实例

    1.5. 为什么自己按照例子写的代码,显示出来总找不到图片 1.6. 我们还需要什么? 1.7. 入门之前,都看helloworld。 1.7.1. 直接使用下载的发布包 1.7.2. 只把必要的东西放进项目中 2. 震撼吧!让你知道ext表格...

    EXT2.0中文教程

    1.5. 为什么自己按照例子写的代码,显示出来总找不到图片 1.6. 我们还需要什么? 1.7. 入门之前,都看helloworld。 1.7.1. 直接使用下载的发布包 1.7.2. 只把必要的东西放进项目中 2. 震撼吧!让你知道ext表格控件...

    Ext 开发指南 学习资料

    1.4. 为什么自己按照例子写的代码,显示出来总找不到图片 1.5. 我们还需要什么? 1.6. 入门之前,都看helloworld。 1.6.1. 直接使用下载的发布包 1.6.2. 只把必要的东西放进项目中 2. 震撼吧!让你知道ext表格控件的...

    GoodProject Maven Webapp.zip

    这意味着可以在不重新加载整个网页的情况下,对网页的某部分进行更新。 传统的网页(不使用 AJAX)如果需要更新内容,必须重载整个网页页面。 系统主要运用在:主要运用于系统的表单验证比如登录注册验证码以及一些...

    EfsFrame(java开发框架) v2.2 源代码.rar

    c)修正分页列表中下面分页条中 分页那里直接输入数字,回车不跳页的问题; d)修改 一个form中同时存在两个datetime的input时,第二个不能选择时分的bug; e)增加 input的 kind与datatype的自动对应关系默认对应...

    EfsFrame(net开发框架) v2.2 源代码.rar

    c)修正分页列表中下面分页条中 分页那里直接输入数字,回车不跳页的问题; d)修改 一个form中同时存在两个datetime的input时,第二个不能选择时分的bug; e)增加 input的 kind与datatype的自动对应关系默认对应...

    EfsFrame(php开发框架) 2.2.rar

    c)修正分页列表中下面分页条中 分页那里直接输入数字,回车不跳页的问题; d)修改 一个form中同时存在两个datetime的input时,第二个不能选择时分的bug; e)增加 input的 kind与datatype的自动对应关系默认对应...

    EfsFrame(php开发框架) v2.2 源代码.rar

    c)修正分页列表中下面分页条中 分页那里直接输入数字,回车不跳页的问题; d)修改 一个form中同时存在两个datetime的input时,第二个不能选择时分的bug; e)增加 input的 kind与datatype的自动对应关系默认对应...

Global site tag (gtag.js) - Google Analytics