我已经被选中了一行,现在我想要获取 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')