Using Context menu with multiple grids

I am trying to use the context menus in multiple grids on one page. I am trying to do something like mygrid.getUserData(rowIdFull,“data”) in thesetContextMenuHandler, but I need to get the mygrid object somehow. Is it possible to share a procedure between 2 grids. The grids will be created dynamically so I can’t hardcode any grid names in.

You can share context menu between multiple grids, but context menu event will receive only row id|cell index. It will not receive info about grid in which event occurs.
You can use onBeforeContextMenu event of grid to receive necessary info.

var context_grid=null;
function set_context(){
context_grid = this;
return true;
}

mygrid1.enableContextMenu(menu);
mygrid1.attachEvent(“onBeforeContextMenu”,set_context);

mygrid2.enableContextMenu(menu);
mygrid2.attachEvent(“onBeforeContextMenu”,set_context);


as result , context_grid will point to last grid instance, for which context menu was called