简体   繁体   中英

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

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.

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

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

试试这个:

grid.getCurrentPosition().row

In ExtJS 7 is:

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

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;
     }
 },

试试

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM