12

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

也许喜欢

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

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

4

6 回答 6

29

这个怎么样?

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

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

于 2013-06-27T10:33:54.797 回答
4

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

listeners: {
    select: function(selModel, record, index, options){
        alert(index);
    }
}
于 2013-06-24T09:09:18.330 回答
2

尝试这个:

grid.getCurrentPosition().row
于 2013-06-24T02:14:28.467 回答
0

在 ExtJS 7 中是:

console.log( 'Selection:', grid.getSelection() ) //One
console.log( 'Selection:', grid.getSelectable().getSelectedRecords() ) //Several
于 2020-08-05T23:15:57.367 回答
0

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

{text: 'Status', dataIndex: 'localizedStatus', width: 150,
     renderer: function(value, meta, record, rowIndex, colIndex, store){
         return value;
     }
 },
于 2021-06-22T08:38:49.903 回答
-2

尝试

grid.getSelectionModel().getSelection()[0].get('id')
于 2013-06-24T02:26:05.667 回答