在ExtJS网格中,我可以得到所选数据项的索引,如下所示:
grid.getSelectionModel().on('rowselect', function(sm, index, rec){
changeMenuItemInfoArea(menuItemApplication, 'you are on row with index ' + index);
var row_number_parts = rec.id.split('-'); // rec.id = e.g. "ext-record-1"
var selected_index = row_number_parts[2] - 1;
alert(selected_index);
});
Run Code Online (Sandbox Code Playgroud)
但是,如何双击获取所选数据项的索引?
当我这样做:
listeners: {
'rowdblclick': function(grid, rowindex, e){
console.log(...);
}
}
Run Code Online (Sandbox Code Playgroud)
既grid和e似乎并不有我需要的,信息rowindex是没有用的,如果用户度假村一列,那么该行的指数双击不一定里面装电网的数据集的指数自.
谢谢@McStretch,我最终解决了手头的问题,将id项目列表中的内容隐藏起来,然后将id发送到编辑页面,如下所示:
listeners: {
'rowdblclick': function(grid, index, rec){
var id = grid.getSelectionModel().getSelected().json[0];
go_to_page('edit_item', 'id=' + id);
}
}
Run Code Online (Sandbox Code Playgroud)
索引实际上是指根据以下文档的商店中记录的索引cellClick:
function(grid, rowIndex, columnIndex, e) {
// Get the Record, this is the point at which rowIndex references a
// record's index in the grid's store.
var record = grid.getStore().getAt(rowIndex);
// Get field name
var fieldName = grid.getColumnModel().getDataIndex(columnIndex);
var data = record.get(fieldName);
}
Run Code Online (Sandbox Code Playgroud)
如果是这种情况,那么您不必担心网格重新排序.我认为你应该通过在你的'rowdblclick'监听器中使用上述方法获得索引/记录- 它更具可读性.测试一下,看看会发生什么.