问题
I have grid with RowSelectionModel:
selModel: {
selType: 'rowmodel',
mode: 'MULTI'
}
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');
}
});
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');
}
回答1:
You can use Ext.selection.RowModel.getSelection(), like this
select: function (rowmodel, record, index, eOpts) {
this.getViewModel().set('record', rowmodel.getSelection());
}
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.
Keep in mind that selectionchange
event is triggered when you select and deselect records and the value can be an empty array.
来源:https://stackoverflow.com/questions/46526934/multiple-row-select-extjs