`

Extjs下拉框多选

阅读更多
[size=medium][size=small]简单的EXTJS多选下拉框

博客分类: EXTJS
extjs下拉框多选extjs combobox带checkbox
看了下网上的下拉框多选扩展示例都太复杂了。本来很简单的东西却搞的那么复杂。
贴贴我的代码 很简单
Java代码  收藏代码
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); 
            } 
        } 
    });
[/size][/size]
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics