Context Menu zoneId is False (Migration 3.6 to 4.1)

I am migrating a personal project from 3.6 to 4.1 (using Standard Edition). The following code works correctly in 3.6, returning a valid value for the grid to which the context menu is attached - in the format rowId_columnId:

menu0.attachEvent("onClick", function(id, zoneId, casState){doContextMenu(id,zoneId,0);});

In v4.1, the zoneId passed to doContextMenu() is false

Is this a bug, or do I need to make some additional changes?

Please, try the next code sample:

[code]

DHTMLX test html,body { width: 100%; height: 100%; margin: 0; }
zone A
zone B
zone C
[/code] Locally it works fine in both STD and PRO 4.1 versions

If this code works correctly with your 4.1 version - we need to see your source code or demo
You can provide it on suport@dhtmlx.com with a link to this topic
docs.dhtmlx.com/auxiliary_docs__ … pport.html

Thanks Darya

I can confirm that the sample code you provided works correctly.

When I use a grid in place of the context zones, there is a problem.

Here is a sample code that reproduces the issue (using the same paths as per the original: my paths are different, since I am using the STD version):

[code]

Demo: Context Menu zoneId returns False html,body { width: 100%; height: 100%; margin: 0; }
[/code]

Please, try to use one of the approaches from samples:
dhtmlx.com/docs/products/dhtmlxG … text_menu/

Thanks Darya - the approach using the grid.contextID property works as long as I know which grid has been clicked on, which in most cases I do, because each grid has its own context menu.

However, I do have a case where the grid is created dynamically, and a standard context menu attached. In these cases, I do not know beforehand which grid is the source of the click, and would need to use the menu’s own context.

(I could create a workaround, allocating each grid a unique context menu when it is set up, but I’d like to avoid that if possible.)

Will the context menu zoneId always be false in v4.1 for a grid?

You can attach onBeforeContextMenu handler for all grids, and from this handler store reference to the current grid. This event will be called before opening context menu, so it is the best place to detect against which greed operation will be executed.

Thanks Stanislav - I’ll try using that approach.