多行选择ExtJS [英] Multiple row select ExtJS
问题描述
我有RowSelectionModel的网格:
I have grid with RowSelectionModel:
selModel: {
selType: 'rowmodel',
mode: 'MULTI'
}
如何在网格中选择很多行?现在我可以选择只有一个记录 me.getViewModel()。get('record')
:
How to select many rows in grid? Now I can select only one record with me.getViewModel().get('record')
:
var me = this;
// Ask user to confirm this action
Ext.Msg.confirm('Confirm Delete', 'Are you sure you want to delete this asset_objects?', function(result) {
// User confirmed yes
if (result == 'yes') {
var record = me.getViewModel().get('record'),
store = Ext.StoreManager.lookup('asset_objects');
// Delete record from store
store.remove(record);
// Sync remote store
store.sync();
// Hide display
me.showView('selectMessage');
}
});
如何将所选记录绑定到viewModel中:
How I bind selected records to the viewModel:
select: function(rowmodel, record, index, eOpts) {
// Set selected record
this.getViewModel().set('record', record);
// Show details
this.showView('details');
}
推荐答案
您可以使用 Ext.selection.RowModel.getSelection(),像这样
select: function (rowmodel, record, index, eOpts) {
this.getViewModel().set('record', rowmodel.getSelection());
}
或代替 select(this,record,index,eOpts)
事件,其中记录
是最后一次所选记录,您可以使用 selectionchange(this,selected,eOpts)
事件,其中选择
是所有选定的记录。
or instead of select ( this, record, index, eOpts )
event, where record
is last selected record, you can use selectionchange ( this, selected, eOpts )
event, where selected
is all selected records.
保留请注意,当您选择并取消选择记录时,会触发 selectionchange
事件,该值可以是空数组。
Keep in mind that selectionchange
event is triggered when you select and deselect records and the value can be an empty array.
这篇关于多行选择ExtJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!