2012-09-06 35 views
1

选项我有一个经柱介绍如何选择只有两个ExtJS的4.1组合框的多选

cols.offer.push({ 
    dataIndex: 'tags', 
    header : 'Тэги', 
    width:150, 
    editor : { 
     xtype : 'combo', 
     store : gridTagStore, 
     queryMode: 'local', 
     displayField: 'name', 
     //valueField: 'name', 
     multiSelect:true, 
     typeAhead: true, 
     editable:false, 
     triggerAction: 'all', 
     selectOnTab: true, 
     lazyRender: true, 
     listClass: 'x-combo-list-small', 
     listeners: { 
      focus: function(e) { 
       this.setValue(this.rawValue.split(', ')); 
      } 
     } 
    } 
}); 

,所以我想选择只有两个组合框中选择一些代码。

,我想,如果我会选择第三个 - 什么都不会发生


的感谢! 它适合我!

cols.offer.push({ 
    dataIndex: 'show_at_index_as_tag_id', 
    header : 'Показывать на главной под тегом', 
    width:150, 
    editor : { 
     xtype : 'combo', 
     store : gridTagStore, 
     queryMode: 'local', 
     typeAhead: true, 
     displayField: 'name', 
     selectOnTab: true, 
     triggerAction: 'all', 
     lazyRender: true, 
     valueField: 'id', 
     multiSelect:true, 
     listClass: 'x-combo-list-small', 
     listeners: { 
       beforeselect : function(){ 
        return (this.value.length == 1 && this.value[0] === "") || this.value.length == 0 ; 
      } 
     } 
    } 
}); 

我决定只有一个选项,以限制和使用多选,因为我有与在应用程序的其他地方使用的选项店。

但我需要在这个组合选择空值,所以多选一个选项选择是很好的解决方案

+1

你现在的问题是什么? –

回答

2

添加beforeselect监听器组合框。在函数中定义在ComboBox中已经选择了多少个项目,如果它的计数> 2 return false;do nothing