Check documentation for the latest version of dhtmlxSuite onContextMenu DHTMLX Docs


fires when the user clicks on treeview items with the right mouse button

void onContextMenu(string|number id,number x,number y,object ev);
idstring|numberthe item's id
xnumberx coordinate
ynumbery coordinate
evobjectwindow event object


// init treeview
var myTreeView = new dhtmlXTreeView("parentId");
// enable context menu
// init 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
    // prevent default context menu
    return false;

Back to top