Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Stephen on Jun 16, 2009 01:15
open dhtmlx forum
dhtmlxFolders menu

>Re previous subject    dhtmlxTree dhtmlxMenu Disable right click browser menu

>Answer posted by dhxSupport on May 29, 2009 07:27
>There is no possibility to block standard browser's context menu only for a specific cell. You can disable browser's standard context >menu only for a whole page.

I have the same problem with Folders placed in a Layout cell. I click on a link in one cell and obtain a list of folders in another cell. If I right click on a folder item I see my context menu with two options (delete, view) but it is immediately covered by the browser's context menu and so is unusable. I have had to resort to having two links, both result in a list of files appearing in a cell:-
1) a link for viewing - click on a file resiults in a popup "do you want to view" window.
2) a link for deleting - click on a file resiults in a popup "do you want to delete" window.
Answer posted by Alex (support) on Jun 16, 2009 07:22

Hello,

you can try to use the following approach to attach dhtmlxMenu as context menu to layout cell (dhtmlxmenu libraries should be included):

 menu = new dhtmlXMenuObject();
 menu.setImagePath("codebase/imgs/");
 menu.renderAsContextMenu();
 menu.addNewChild(menu.menuId,0,"view","View")
 menu.addNewSibling(""view","delete","Delete");

 dhxLayout.cells("a").oncontextmenu = function(e){
  var ev =(e||event); 
  ev.cancelBubble = true;
  menu.showContextMenu(ev.clientX,ev.clientY)
  return false;
};
menu.attachEvent("onClick", function(id){
...
});


Answer posted by Stephen on Jul 09, 2009 08:23
Thank you Alex this works.
But how can I obtain the node itemId in
menu.attachEvent("onClick", function(id){
The parameter id is the menu selection not the node.
I could use another event
folder.attachEvent("onBeforeContextMenu", function(itemId){
and set a global variable to be used eg
   g_itemId = itemId;
but there must be a better way.
 
Answer posted by Alex (support) on Jul 09, 2009 09:18
Folders has contextID property that contains the id  of the folder:
menu.attachEvent("onClick", function(id){
var folderId = folder.
contextID;
...
}