Extjs多選下拉框02

直接在需要使用的頁面中的組件更改即可,例子如下:

{
								  fieldLabel:'多選下拉框',
								  triggerAction:'all',
								  id:'multiselect',
								  name:'multiselect',
								  xtype: 'combo',
								  width:100,
								  emptyText:'請選擇',
								  store:manStore,
								  mode:'local',
								  valueField:'value',
								  displayField:'value',
								  //editable:false,
								  frame:true,
								  
					        typeAhead: true,   
					        tpl:'<tpl for="."><div class="x-combo-list-item"><span><input type="checkbox" {[values.check?"checked":""]}  value="{[values.value]}" /></span><span >{value}</span></div></tpl>',     
					        selectOnFocus:true,
					        //value:'',
					        //applyTo: 'local-states',   
					        onSelect : function(record, index){   
					            if(this.fireEvent('beforeselect', this, record, index) !== false){   
					                record.set('check',!record.get('check'));   
					                var str=[];//頁面顯示的值   
					                var strvalue=[];//傳入後臺的值   
					                this.store.each(function(rc){   
					                    if(rc.get('check')){   
					                        str.push(rc.get('value'));   
					                        strvalue.push(rc.get('value'));   
					                    }   
					                });   
					                this.setValue(str.join());   
					                this.value=strvalue.join();   
					                //this.collapse();   
					                this.fireEvent('select', this, record, index);  
					                
					            }   
					        }
							}

這方法避免了前篇中提到的出現bug的問題。而且簡單不用加載附件。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章