Right click on a context menu for multiple grids

I have created a context menu for a grid which is working by calling:

myMenu.attachEvent(“onClick”, onButtonClick);

which i then attach to my grid:

myGridIII.enableContextMenu(myMenu);

it calls the onButtonClick and passes in menuitemId (in this case, 'add).

I’d like to be able to use this onButtonClick logic on more than one grid. Currently in onButtonClick I have the line:

var data = myGridIII.contextID.split(“_”);

Which means onButtonClick only works for one grid. I’d like to be able to make it a little more flexible by passing in the id of the grid. I’ve searched the events and found this:

docs.dhtmlx.com/api__dhtmlxmenu_ … event.html

But it won’t pass in the actual grid i’m currently right-clicking on, at most I can get the option selected (Add/Remove) and row/column Ids. I don’t see a way to pass in the grid I’m right clicking on. Is there a way to reuse this code or am i missing something?