Check documentation for the latest version of dhtmlxSuite enableContextMenu DHTMLX Docs

enableContextMenu

enables context menu

void enableContextMenu(boolean mode);
modebooleantrue to enable context menu, false to disable it

Example

// initialize treeview
var myTreeView = new dhtmlXTreeView("parentId");
 
// enable context menu
myTreeView.enableContextMenu(true);
 
// initialize dhtmlx menu
var myContextMenu = new dhtmlXMenuObject({
    context: true // render it as context menu
});
 
myTreeView.attachEvent("onContextMenu", function(id, x, y, ev){
    // show context menu here
    myContextMenu.showContextMenu(x, y);
 
    // optionally, you can select treeview item
    myTreeView.selectItem(id);
 
    // prevent default context menu
    return false;
});

Back to top