我正在使用多选分组组合框(带有复选框),我想为组提供选择/取消选择功能。
var tpl = new Ext.create('Ext.XTemplate',
'<tpl for=".">',
'<tpl for="group" if="this.shouldShowHeader(group)"><div class="group-header">{[this.showHeader(values.group)]}</div></tpl>',
'<div class="x-boundlist-item"><input type="checkbox" />{name}</div>',
'</tpl>', {
shouldShowHeader: function(group) {
return this.currentGroup !== group;
},
showHeader: function(group) {
this.currentGroup = group;
return group;
}
});
var data = [{
group: 'Fubar',
key: '1',
name: '2015 Product Development'
}, {
group: 'Fubar',
key: '2',
name: 'Message Filter'
}, {
group: 'Fubar',
key: '3',
name: '2014 Product Development (Little)'
}, {
group: 'Other',
key: '4',
name: 'Global Structure'
}, {
group: 'Other',
key: '5',
name: 'My SW'
}];
Ext.create('Ext.container.Container', {
renderTo: Ext.getBody(),
width: '70%',
padding: 10,
layout: {
type: 'vbox',
align: 'stretch'
},
items: [{
xtype: 'combobox',
id: 'searchInput',
store: combo,
multiSelect: true,
labelWidth: 50,
queryMode: 'local',
displayField: 'name',
fieldLabel: 'Choose',
listConfig: {
cls: 'grouped-list'
},
tpl: tpl,
}]
});
我尝试了以下功能来添加/删除组合框中的项目,但是我不知道如何继续,这里我需要从组合框选择的列表中删除项目(仅适用于所选组) 如果已选中该复选框,则添加保留当前所选项目+所选组中所有项目的项目。
selectDeselectAllGroupItems = function (groupHeader) {
var selectedGroup = groupHeader.getAttribute('group');
var currentKey = getComboKey(combo);
Ext.each(combo.pickerSelectionModel.selected.items, function (rec) {
if (rec.getData().group == selectedGroup) {
//combo.store.remove(rec);
//var index = this.data.indexOf(rec);
//this.fireEvent("remove", this, rec, index);
}
});
}