extjs combobox分页查询
生活随笔
收集整理的這篇文章主要介紹了
extjs combobox分页查询
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
IE6.0++
extjs3.3.1
以下就是代碼:
/** * YHC */ /** * 分頁的Combobox */ PagingMedicalcareCbo=Ext.extend(Ext.form.ComboBox,{ /** * 構(gòu)造方法 */ timedelay_Slow:2000,//1000ms=1s timedelay_fast:1000,//1000ms=1s t:null, myStore:null, currentCboText:null,//當(dāng)前CBO文本框中的值 constructor:function(){ 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", store:this.myStore, mode:"remote", pageSize:5, triggerAction:"all", displayField:"orgName", //valueField:"linkId", width:180, listWidth:220, fieldLabel:'醫(yī)療單位', listeners :{ select:this.onSelected, keyup:this.onKeyup, scope:this } }); }, //設(shè)置參數(shù) onCboBeforeLoad:function(store,options){ if(this.currentCboText!=null&&(typeof this.currentCboText)!='undefined'){ //帶機(jī)構(gòu)名稱 store.baseParams={'medicalCareVo.orgName':this.currentCboText}; }else{ //沒有任何的參數(shù) store.baseParams={}; } }, //選擇之后,對應(yīng)賦值 onSelected:function(combo,record,index){ var orgName=this.myStore.getAt(index).get('orgName'); //this.value=orgName; alert(this.myStore.getAt(index).get('orgName')); }, //鍵盤彈起的時候 ,賦值當(dāng)前文本值 onKeyup:function(combo,e){ this.currentCboText=Ext.getCmp('searchCbo').getValue(); //切記 清除(很重要) 下一次需要清除上一次 if(this.t){ window.clearInterval(this.t);//清除延時執(zhí)行 } //如果此時用戶將文本框的值刪除完之后(也就是沒有任何的值) if(this.currentCboText==''){ this.t=window.setInterval('Ext.getCmp("searchCbo").myStoreLoadData()', this.timedelay_fast); return; } //延時執(zhí)行,避免用戶輸入太快,導(dǎo)致訪問服務(wù)器次數(shù)增加,節(jié)約性能 this.t=window.setInterval('Ext.getCmp("searchCbo").myStoreLoadData()', this.timedelay_Slow); }, //--myStore重新加載數(shù)據(jù) myStoreLoadData:function(){ //重新加載數(shù)據(jù) this.myStore.load({ params:{start:0,limit:5} }); //切記 清除(很重要) if(this.t!=null){ window.clearInterval(this.t);//清除延時執(zhí)行 } } });在調(diào)用延時的時候需要使用字符串調(diào)用:
this.t=window.setInterval('Ext.getCmp("searchCbo").myStoreLoadData()', this.timedelay_Slow);還有切記使用Ext的方法,不能使用this.方法名(錯誤),正確的是我上面寫的方式.在調(diào)用的時候需要使用字符串,才能延時調(diào)用,否則不可以,切記切記....
轉(zhuǎn)載于:https://www.cnblogs.com/hibernate3-example/archive/2012/04/18/2492388.html
與50位技術(shù)專家面對面20年技術(shù)見證,附贈技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的extjs combobox分页查询的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 能简单描述一下美宜佳便利店吗?
- 下一篇: 马上要见老丈人,老丈人喜欢喝红酒,第一次