Grid Contextmenu on leftclick


your example in is nice, but we need the contextmenu to render on leftclick. Is that possible?

It’s important that the menu knows which row it is over to load custom data.

Please check this example … _menu.html

dhtmlxMenu appears when you open cell editor. You can configure grid to open cell editor with single click with enableEditEvents() method … editevents


on leftclick only contextmenu shall be shown - we don’t want to edit the cell (It is fix with an image in it).

At the moment we have an image in each cell of the first column with a contextmenu on the column.
On rightklick menu with options is shown and logic for opening jsp-pages on click on menu item is implemented.

Only problem ist that it only opens on rightklick.

You can attach “onclick” event to the image and show context menu manually. To show/hide context menu you can use dhtmlxMenu API … _toc_alpha

Here’s a way to show the context menu on left click:

  1. define the menu:
menu = new dhtmlXMenuObject(); 
... add the items
  1. add this prototype:
dhtmlXGridObject.prototype.onClick = function(cb){	
  var that=this;
     var el  = that.getFirstParentOfType(_isIE?,"TD");
     var rId = el.parentNode.idd;
     var cId = el._cellIndex;
        if (rId == undefined || cId == undefined  ) { 
            /// -- write a standard cancel event function or call one app.cancelEvent(e);
      var v   = that.cells(rId, cId).getValue()
      cb.apply(that, [rId, cId, v, e]);
  1. Add the onClick event to the grid and open the menu:
grid.onClick(function(rId, cId, val, e){
    if (cId !=0 ) return;  // open only on the first cl
    window.setTimeout(function(){ menu._doOnContextBeforeCall(e,{id:rId})}, 1)