Grid Contextmenu on leftclick

Hi,

your example in http://www.dhtmlx.com/docs/products/dhtmlxGrid/samples/03_context_menu/02_pro_context_column.html 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
dhtmlx.com/docs/products/dht … _menu.html

dhtmlxMenu appears when you open cell editor. You can configure grid to open cell editor with single click with enableEditEvents() method docs.dhtmlx.com/doku.php?id=dhtm … editevents

Hi,

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 docs.dhtmlx.com/doku.php?id=dhtm … _toc_alpha

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

  1. define the menu:
menu = new dhtmlXMenuObject(); 
menu.renderAsContextMenu();
... add the items
  1. add this prototype:
dhtmlXGridObject.prototype.onClick = function(cb){	
  var that=this;
  dhtmlxEvent(that['obj'],"click",function(e){
     var el  = that.getFirstParentOfType(_isIE?event.srcElement:e.target,"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);
             return;
         }
      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)
});