有两种方法可以从
MultiSelector
-
使用
multiSelector.getStore().getData().items
-此存储区仅包含搜索弹出窗口中选定的数据。此存储将在搜索网格的选择更改时填充。
-
使用
multiselector.searchPopup.down('grid').getSelection()
两种方法都将返回您选择的记录
multiselector
.
在这
FIDDLE
,我创建了一个演示
多选机
.
代码片段
Ext.application({
name: 'Fiddle',
launch: function () {
Ext.create({
xtype: 'panel',
bodyPadding: 10,
title: 'MultiSelector',
renderTo: Ext.getBody(),
tbar: [{
text: 'Get Selected recrod',
handler: function () {
var multiselector = this.up('panel').down('multiselector'),
data = multiselector.getStore().getData().items;
alert(`Total record selected number is ` + data.length);
//Get selected record by searchPopup
if (multiselector.searchPopup) {
console.log('Get selected record by searchPopup', multiselector.searchPopup.down('grid').getSelection().length);
}
}
}],
items: [{
xtype: 'multiselector',
valueField: 'id',
displayField: 'name',
showDefaultSearch: true,
plusButtonType: 'add',
hideHeaders: true,
colspan: 2,
search: {
xtype: 'multiselector-search',
store: {
type: 'store',
fields: ['id', 'name'],
autoload: true,
data: [{
id: 1,
name: 'Option 1 -- I want to get this'
}, {
id: 2,
name: 'Option 2 -- I want to get this'
}, {
id: 3,
name: 'Option 3 -- I want to get this'
}, {
id: 4,
name: 'Option 4 -- I want to get this'
}, {
id: 5,
name: 'Option 5 -- I want to get this'
}, {
id: 6,
name: 'Option 6 -- I want to get this'
}, {
id: 7,
name: 'Option 7 -- I want to get this'
}]
}
}
}]
});
}
});