DeLe
DeLe

Reputation: 2480

Extjs - Get rowIndex of a selected row

I have been seleted a row, and now i want get rowIndex

maybe like

grid.getSelectionModel().getSelection()[0].rowIndex

but it's undefined. How can i get it thanks

Upvotes: 12

Views: 64099

Answers (6)

if you need modify a column in a grid, you can use this code snapshot:

{text: 'Status', dataIndex: 'localizedStatus', width: 150,
     renderer: function(value, meta, record, rowIndex, colIndex, store){
         return value;
     }
 },

Upvotes: 0

pedro.caicedo.dev
pedro.caicedo.dev

Reputation: 2435

In ExtJS 7 is:

console.log( 'Selection:', grid.getSelection() ) //One
console.log( 'Selection:', grid.getSelectable().getSelectedRecords() ) //Several

Upvotes: 1

wonu wns
wonu wns

Reputation: 3608

how about this?

var selectedRecord = grid.getSelectionModel().getSelection()[0];
var row = grid.store.indexOf(selectedRecord);

you have to get the selected record of your grid and from that, you can search this record from your store and get its index.

Upvotes: 30

Aminesrine
Aminesrine

Reputation: 2140

you can also get it from the select listener of the grid:

listeners: {
    select: function(selModel, record, index, options){
        alert(index);
    }
}

Upvotes: 4

ytppa
ytppa

Reputation: 1

Try

grid.getSelectionModel().getSelection()[0].get('id')

Upvotes: -2

player
player

Reputation: 610

Try this:

grid.getCurrentPosition().row

Upvotes: 2

Related Questions