[英]Extjs - Get rowIndex of a selected row
I have been seleted a row, and now i want get rowIndex我已经被选中了一行,现在我想要获取 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:您还可以从网格的select
侦听器中获取它:
listeners: {
select: function(selModel, record, index, options){
alert(index);
}
}
试试这个:
grid.getCurrentPosition().row
In ExtJS 7 is:在 ExtJS 7 中是:
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')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.