Reputation: 11
i have some code that describes by column
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(', '));
}
}
}
});
so I want to select only two options in combobox.
and I want if I would select third - nothing will happen
thanks! it works for me!
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 ;
}
}
}
});
I decided to limit with only one option and to use multiselect because I have store with options that is being used in other places of application.
But I need to select empty value in this combo, so multiselection with one option select is the good solution
Upvotes: 1
Views: 3179
Reputation: 17000
Add beforeselect
listener to ComboBox. In the function define how many items already selected in ComboBox, if its count > 2 return false;
to do nothing
.
Upvotes: 2