Context menu in a subgrid invokes parent grid.

Hi,



The call back function to the “onBeforeContextMenu” event attached to a subgrid is invoked for both subgrid and parent grid when the subgrid is “right-clicked”. The first two parameters, namely RowId and CellIdx are from the subgrid for the two invocations; whereas the third Grid parameter refers to both subgrid and parent grid correspondingly. Finally the “onButtonClick” function is fired on the parent grid and not on the subgrid.



NOTE: In my use-case, i am loading the parent and sub-grid using loadXMLString() function.



Please let me know how to cancel the invocation of the parent grid when the subgrid’s context menu is selected/clicked.



The following javascript island when executed with the pro_subgrids.html would illustrate the point.



    

    





    

    

        

        

    







Thanks.

mygrid.enableContextMenu(menu);
mygrid.attachEvent(“onBeforeContextMenu”,my_pre_func);

Delele this rows and context menu will invoke only for tthe sub grid.

the invocation of the parent grid when the subgrid’s context menu is selected/clicked.
If you are using the same menu object for both top and sub grids, it will trigger event code attached to onButtonClick without relation to grid from which menu was opened.
You can use different context menu or lock last active grid instance through onBeforeContextMenu event.

>>The call back function to the “onBeforeContextMenu” event attached to a subgrid is invoked for both subgrid and parent grid when the subgrid is "right-clicked"
This is an unexpected side effect of current implementation.
Issue will be fixed in next version, for now you can update source code as

dhtmlxgrid.js , line 1185
if (this._ctmndx.showContextMenu){

} else {

}
can be replaced with
if (this._ctmndx.showContextMenu){

} else {

}
ev.cancelBubble=true;