繁体   English   中英

Extjs - 获取选定行的 rowIndex

[英]Extjs - Get rowIndex of a selected row

我已经被选中了一行,现在我想要获取 rowIndex

也许喜欢

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

但它是未定义的。 我怎样才能得到它谢谢

这个怎么样?

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

您必须获取网格的选定记录,然后从您的商店中搜索该记录并获取其索引。

您还可以从网格的select侦听器中获取它:

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

试试这个:

grid.getCurrentPosition().row

在 ExtJS 7 中是:

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

如果需要修改网格中的列,可以使用此代码快照:

{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.

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