`
chinawomen
  • 浏览: 23763 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

简单的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);
			}
		}
    });
 
5
3
分享到:
评论
8 楼 myyugioh 2013-09-16  
guo0928guo 写道
怎么默认勾选多个下拉项呢

record.set('check','true')); 
7 楼 guo0928guo 2013-07-11  
怎么默认勾选多个下拉项呢
6 楼 myyugioh 2013-04-16  
题,在3.1版本里选择多个选项时,getValue无法拿到valueField的值,只能拿到displayField的值,有什么解
henchong 写道
有个问题,在3.1版本里选择多个选项时,getValue无法拿到valueField的值,只能拿到displayField的值,有什么解决办法?我的也是遇到这个问题了,求解决

重写getValue方法
5 楼 henchong 2013-04-16  
有个问题,在3.1版本里选择多个选项时,getValue无法拿到valueField的值,只能拿到displayField的值,有什么解决办法?我的也是遇到这个问题了,求解决
4 楼 myyugioh 2012-09-27  
有个问题,在3.1版本里选择多个选项时,getValue无法拿到valueField的值,只能拿到displayField的值,有什么解决办法?
3 楼 ychizhiyiheng 2011-10-10  
OK!  谢谢你!
2 楼 jianhao84 2011-09-07  
好像搞不定啊,求指导:qq 287360083
1 楼 JavaSky66 2011-08-12  
很不错....。

相关推荐

Global site tag (gtag.js) - Google Analytics