간단한 EXTJS 다중 선택 드롭다운 상자

다음 인터넷의 하단 상자를 봤는데 확장 예시가 너무 복잡해요.원래 쉬운 걸 그렇게 복잡하게 만들어.
내 코드를 붙이는 것은 매우 간단하다
var store = new Ext.data.SimpleStore({
        fields: ['abbr', 'state', 'nick'],
        data : Ext.exampledata.states // from states.js
    });
    var combo = new Ext.form.ComboBox({
        store: store,
        displayField:'state',
		valueField:'abbr',
        typeAhead: true,
        mode: 'local',
		//tpl:'<tpl for="."><div ><span><input type="checkbox" onclick="myclick(this)" value="{state}" /></span><span class="x-combo-list-item">{state}</span></div></tpl>',
		tpl:'<tpl for="."><div class="x-combo-list-item"><span><input type="checkbox" {[values.check?"checked":""]}  value="{[values.state]}" /></span><span >{state}</span></div></tpl>',
        triggerAction: 'all',
        emptyText:'select...',

       // xtype:'button',
        selectOnFocus:true,
        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('state'));
						strvalue.push(rc.get('abbr'));
					}
				});
				this.setValue(str.join());
				this.value=strvalue.join();
				//this.collapse();
				this.fireEvent('select', this, record, index);
			}
		}
    });

좋은 웹페이지 즐겨찾기