EXTJS 3.3 下來列表combox的多選方式
阿新 • • 發佈:2019-01-01
tbar:[{ text : "頻道:" }, new Ext.form.ComboBox{ id:"nextDayShowchannelid", name: "nextDayShowchannelid", store : new storeCombo({}), enableKeyEvents: true, typeAhead: true, mode: 'local', tpl:'<tpl for="."><div class="x-combo-list-item"><span><input type="checkbox" {[values.check?"checked":""]} value="{[values.id]}" /></span><span >{name}</span></div></tpl>', triggerAction: 'all', displayField:'name', valueField:'id', frame:true, width:350, selectOnFocus:true, onSelect : function(record, index){ if(this.fireEvent('beforeselect', this, record, index) !== false){ record.set('check',!record.get('check')); var str=[];//頁面顯示的值 var strvalue=[];//傳入後臺的值 nextDayShowAjaxData=""; this.store.each(function(rc){ if(rc.get('check')){ str.push(rc.get('name')); strvalue.push(rc.get('id')); if(nextDayShowAjaxData!=""){ nextDayShowAjaxData+=","; } nextDayShowAjaxData +=rc.get('id'); } }); this.setValue(str.join()); this.value=strvalue.join(); this.fireEvent('select', this, record, index); } } })
設 nextDayShowAjaxData 為全域性變數,可以通過nextDayShowAjaxData遍歷最後選完所要選的check後;
nextDayShowAjaxData 在check之前必須設為空,否則會有每次會重複以前所選的