extjsextjs7

ExtJS 7 Modern : Retrieve grid selected rows


I have a grid with checkbox selection to allow multiple rows selection.

Ext.define("app.view.grid.MyGrid", {
  extend: "Ext.grid.Grid",
  xtype: "app.MyGrid",

  viewModel: "Grid",

  selectable: {
    rows: true,
    checkbox: true,
  },

But now, how can I get all the selected rows? If I use grid.getSelection(), it only shows the latest selected row. I saw many answers using grid.getSelectionModel().getSelection() but this works on Classic toolkit, I am using 7.4 Modern.

If I try, it gives me getSelectionModel() is not a function and this method is not available anymore : https://docs.sencha.com/extjs/7.4.0/modern/Ext.grid.Grid.html#event-select

Thank you


Solution

  • Try grid.getSelections(), in modern toolkit it should return an array with the selected items.