Closed sanx72 closed 4 years ago
The problem with your code is that the datagrid has its own context menu events so presumably its firing that one rather than the body context menu event. All you need to do is switch to using the event on the datagrid rather than the body.
We have several examples of context menus on the datagrid: http://latest-enterprise.demo.design.infor.com/components/datagrid/test-contextmenu.html http://latest-enterprise.demo.design.infor.com/components/datagrid/test-contextmenu-on-specific-columns.html http://latest-enterprise.demo.design.infor.com/components/datagrid/test-contextmenu-in-events.html http://latest-enterprise.demo.design.infor.com/components/datagrid/test-contextmenu-firstclick.html http://latest-enterprise.demo.design.infor.com/components/datagrid/test-contextmenu-dynamic.html
Best way thats closest would be..
$('#datagrid').datagrid({
columns: columns,
dataset: data
}).on('contextmenu', function (e, args) {
console.log('contextmenu fired do your popupmenu', args);
});
Possibly this is due to being able to now veto the contextmenu event manually but this is the opposite of what your doing.... Potentially this line https://github.com/infor-design/enterprise/blob/master/src/components/datagrid/datagrid.js#L6015
Other workarounds... Turn off ours..
$('#datagrid').off('contextmenu.datagrid');
Or attach to both
$('body, #datagrid').on('contextmenu', function () {
window.console.log(evt);
$("body").popupmenu({...});
return false;
});
@tmcconechy $('#datagrid').off('contextmenu.datagrid');
works in the testPage example so I'll try that in our production code, thanks
Considering this done as long as you can make that work
Switching the event off immediately after we create data grids in our application restores the original behaviour so happy to go with that.
In our code we have a oncontextmenu event on the body of the page so that when the user right-clicks anywhere on the page, we can then show our own menu using the PopupMenu control with the "immediate" option.
This used to work OK on all IDS controls until we upgraded to IDS 4.23. Now, it no longer works on the DataGrid. Right Click on the DataGrid causes a JQuery Event instead of a MouseClick Event which then breaks the PopupMenu call which expects a MouseEvent (I think).
Tested in Chrome and Firefox (latest versions) on Windows 8.1
Here is an example code fragment you can plug into your standard IDS template (full page test included as ZIP attachment)...
In the console, right-click on the page shows a MouseEvent and right-click on the table shows a JQuery Event...
testPage.zip
How do work around this so that oncontextmenu can be used for datagrid and all other controls?