Extjs - Get rowIndex of a selected row
Asked Answered
T

6

12

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

Tend answered 24/6, 2013 at 1:48 Comment(0)
C
30

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.

Childbirth answered 27/6, 2013 at 10:33 Comment(1)
That helped. Just wanted to add that you don't need .getSelectionModel()Toiletry
B
4

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

listeners: {
    select: function(selModel, record, index, options){
        alert(index);
    }
}
Betthezel answered 24/6, 2013 at 9:9 Comment(0)
E
2

Try this:

grid.getCurrentPosition().row
Endothermic answered 24/6, 2013 at 2:14 Comment(1)
almost! try grid.getSelectionModel().getCurrentPosition()Sielen
Z
1

In ExtJS 7 is:

console.log( 'Selection:', grid.getSelection() ) //One
console.log( 'Selection:', grid.getSelectable().getSelectedRecords() ) //Several
Zoi answered 5/8, 2020 at 23:15 Comment(0)
B
0

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;
     }
 },
Bactericide answered 22/6, 2021 at 8:38 Comment(0)
Z
-2

Try

grid.getSelectionModel().getSelection()[0].get('id')
Ziska answered 24/6, 2013 at 2:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.