Steve
Steve

Reputation: 111

How can I get selected records from ExtJS grid that uses a checkboxmodel

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?

Upvotes: 11

Views: 44036

Answers (5)

pablodcar
pablodcar

Reputation: 828

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

Upvotes: 26

aswininayak
aswininayak

Reputation: 973

simply by using getSelection() like this :

var selectedRecordsArray = grid.getView().getSelectionModel().getSelection();

Upvotes: 4

Dipen Soni
Dipen Soni

Reputation: 41

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

Upvotes: 0

zengsong
zengsong

Reputation: 31

var arrayList=[],
 selected=Ext.getCmp('wpDetaPrdsDetailGrid').getView().getSelectionModel().getSelection();
                    Ext.each(selected, function (item) {
                       arrayList.push(item.data);                    
});

Upvotes: 3

seasonedgeek
seasonedgeek

Reputation: 160

Your grid checkbox question is addressed on the the Sencha Ext JS 3.x Community Forum.

Upvotes: 0

Related Questions