Multiple row select ExtJS

2019-06-06 05:39发布

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');
}

标签: Extjs extjs6
1条回答
爷的心禁止访问
2楼-- · 2019-06-06 06:27

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.

查看更多
登录 后发表回答