【发布时间】:2011-05-22 07:46:39
【问题描述】:
在 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);
});
但是如何在双击时获取所选数据项的索引?
当我这样做时:
listeners: {
'rowdblclick': function(grid, rowindex, e){
console.log(...);
}
}
grid 和 e 似乎都没有我需要的信息,rowindex 也没有用,因为如果用户使用一列,那么双击的行的索引不一定是加载网格的数据集的索引。
附录
感谢@McStretch,我最终解决了手头的问题,将id 放在项目列表中,隐藏id 列,然后将id 发送到编辑页面,如下所示:
listeners: {
'rowdblclick': function(grid, index, rec){
var id = grid.getSelectionModel().getSelected().json[0];
go_to_page('edit_item', 'id=' + id);
}
}
【问题讨论】: