View Full Version : how to get selected row indexes of extjs grid

25 Aug 2011, 4:25 AM
I have an extjs grid and i have used checkbox selection model.When i select multiple rows and click on a button I need to get the row indexes of each of selected rows. Currently i have done is

var button = new Ext.Button({
text: 'submit',
handler:function() {
var selection = grid.getSelectionModel().getSelections();
var name='';
for(var i = 0; i < selection.length ; i++){
var gridrecord = grid.getSelectionModel().getSelected();
name += (name===''?'':'')+selection[i].get('title');
var rowIndex = grid.getStore().indexOf(gridrecord);



As you can see i can get the title of all the selected rows but i am getting only the first selected row index. I need to get row index of all the selected rows

I have wasted a whole day trying to find a solution for this.Can anybody help to find a solution for this?

25 Aug 2011, 5:09 AM
To make it simpler... Is there any way to get row indexes of multiple rows?

25 Aug 2011, 7:55 AM
Sure. What I would do is get the selected record, and the store the indexies in an array. Something like:

var selectedRowIndexes = [];

// returns an array of selected records
var selectedBanners = grid.getSelectionModel().getSelections();

Ext.iterate(selectedBanners, function(banner, index) {
// push the row indexes into your array

That work?

25 Aug 2011, 8:41 PM
Excellent.. this was what i was looking for..thanks a lot .. :)

11 Dec 2012, 4:59 AM
Worked for me too! Thumbs Up!:)

14 Aug 2013, 4:16 AM
I am getting an error like this
TypeError: Ext.grid.getSelectionModel is not a function