Dojo 1.5. I have an enhanced grid that has a rowMenu defined like so:
<div dojoType="dijit.Menu" id="rowMenu" style="display: none;">
<div dojoType="dijit.MenuItem" id="menuUsers">Add/Edit Users</div>
</div>
I listen to the onclick for that menu item like this:
dojo.connect(dijit.byId("menuUsers"), "onClick", addEditUsers);
If I try to use e.rowIndex in addEditUsers, it is undefined. The only way I've been able to figure out how to get the row the user right clicks on is by a separate row listener:
dojo.connect(dijit.byId("grid"), "onRowContextMenu", rowContextMenu);
From rowContextMenu(), e.rowIndex is available, so I can get row data using
var item = e.grid.getItem(e.rowIndex);
console.log(e.grid.store.getValue(item, 'name')); // this will show the value of a 'name' column for the row the user right clicked.
So I could use this to toggle a global/object (e.g. currentContextItem), but it seems like there's gotta be an easier approach. Is there not a direct way to get at the rowIndex/data from the context menu item listener? Note that I cannot use grid.selection.getSelected() because that is whatever row the user last left clicked on.