Given that I've got a ExtJS grid using a CheckBoxModel, what is the best way to get a list of all the records where the checkbox is checked?
Asked
Active
Viewed 4.4k times
5 Answers
25
In ExtJS 4, to select records in a grid with selection model as Ext.selection.CheckboxModel do:
var selectedRecords = grid.getSelectionModel().getSelection();
// And then you can iterate over the selected items, e.g.:
selected = [];
Ext.each(selectedRecords, function (item) {
selected.push(item.data.someField);
});
I hope this helps

Anders Metnik
- 6,096
- 7
- 40
- 79

pablodcar
- 798
- 1
- 6
- 15
-
2You can also do the following to save a few lines: Ext.pluck(grid_selection, 'data') – postrational Jun 17 '12 at 20:28
-
1@postrational FWIW, Ext.pluck is deprecated http://docs.sencha.com/extjs/4.2.2/#!/api/Ext-method-pluck (as of 4.0.0, use Ext.Array.pluck instead). – Josh Jul 18 '14 at 15:57
3
simply by using getSelection()
like this :
var selectedRecordsArray = grid.getView().getSelectionModel().getSelection();

Lars
- 2,315
- 2
- 24
- 29

aswininayak
- 933
- 5
- 22
- 39
0
var SelectedCheckbox=grid.getSelectionModel();
for(i=0;i<SelectedCheckbox.selections.length;i++){
console.log(SelectedCheckbox.selections.items[i].data.field_name);
}

Dipen Soni
- 41
- 3
0
Your grid checkbox question is addressed on the the Sencha Ext JS 3.x Community Forum.

seasonedgeek
- 160
- 6