In an ExtJS grid, I can get the index of the selected data item like this:
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);
});
But how do I get the index of the selected data item on double click?
When I do this:
listeners: {
'rowdblclick': function(grid, rowindex, e){
console.log(...);
}
}
both grid
and e
don't seem to have the information I need and rowindex
isn't useful since if the user resorts a column, then the index of the row double-clicked is not necessarily the index of the dataset which loaded the grid.
Addendum
Thanks @McStretch, I ultimately solved the issue at hand by putting the id
in the item list, hiding the id column, then sending the id to the edit page, like this:
listeners: {
'rowdblclick': function(grid, index, rec){
var id = grid.getSelectionModel().getSelected().json[0];
go_to_page('edit_item', 'id=' + id);
}
}