Extjs -获取所选行的rowIndex

vwhgwdsa  于 2022-11-04  发布在  其他
关注(0)|答案(6)|浏览(257)

我已经选择了一行,现在我想获取rowIndex
也许像

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

但是没有定义.我怎么才能得到它谢谢

332nm8kg

332nm8kg1#

这个怎么样?

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

你必须得到你的网格的选定记录,然后,你可以从你的存储中搜索这个记录,并得到它的索引。

xqnpmsa8

xqnpmsa82#

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

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

mbzjlibv3#

试试看:

grid.getCurrentPosition().row
woobm2wo

woobm2wo4#

在ExtJS 7中为:

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

k97glaaz5#

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

{text: 'Status', dataIndex: 'localizedStatus', width: 150,
     renderer: function(value, meta, record, rowIndex, colIndex, store){
         return value;
     }
 },
wwwo4jvm

wwwo4jvm6#

尝试

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

相关问题