Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Saurabh Malviya on Jun 02, 2009 07:23
open dhtmlx forum
DHTMLXContextMenu

How to disable browser context menu from grid's context menu zone? (After implementing contextmenu in grid, both the context menu are coming i.e. dhtmlxcontextmenu as well as browser's context menu)
Answer posted by Support on Jun 02, 2009 07:45
You can add the next code to grid's init, which must fully block native context menu

dhtmlxEvent(mygrid.entBox,"contextmenu",function(){
        return false;
})

Similar fix already was added to the main codebase, and will be included in next release. 
Answer posted by Saurabh Malviya on Jun 12, 2009 04:20
Where should I exactly place this patch of code so that native context menu is completely blocked.
I tried placing it before and after mygrid.init() as below but nothing seems working.

mygrid.init();
dhtmlxEvent(mygrid.entBox,"contextmenu",function(){
      return false;
});

or
dhtmlxEvent(mygrid.entBox,"contextmenu",function(){
      return false;
});

mygrid.init();


Answer posted by Alex (support) on Jun 12, 2009 05:55

Hello,

this code should be added after grid initialization. Please add also code that blocks bubbling - possibly this modification will fix the issue:

mygrid = new dhtmlXGridObject('gridbox');
dhtmlxEvent(mygrid.entBox,"contextmenu",function(e){
  (e||event).cancelBubble = true
  return false;
})


Answer posted by Tejas Shah on Jun 12, 2009 06:37
Hi there,

I wish to ask that where can I put the given patch, before init() ?, after init() ? or some where else ?
I put an alert in the code. Its alertnig it, but not disabling the browser's default context menu.
I just wish to disable the default context menu and show DHX menu. It was working in the v1.6 but not in 2.
Why is it so ?

Please reply.