[英]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.