Multiple row select ExtJS

谁都会走 提交于 2019-12-08 04:05:42

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!