DHTMLX Docs & Samples Explorer

Custom onRightClick handler

"onRightClick" event handler allows to set function called when cell is right clicked


Source
<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxgrid.css">
<link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxgrid_dhx_skyblue.css">
<script  src="../../codebase/dhtmlxcommon.js"></script>
<script  src="../../codebase/dhtmlxgrid.js"></script>
<script  src="../../codebase/dhtmlxgridcell.js"></script>
 
 
 
 <div style="height:20px;">
    <div id="a_1" style="color:red;display:none">item was right clicked</div>
</div>
<table width="600px">
    <tr>
        <td>
            <div id="gridbox" style="width:100%;height:270px;background-color:white;"></div>
        </td>
    </tr>
</table>
<br>
<script>
function onButtonClick(rowId, cellId); {
    document.getElementById("a_1").style.display = "block";
    document.getElementById("a_1").innerHTML = "cell (" + rowId + "," + cellId + ") was right clicked";
    return false;
}
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("../../codebase/imgs/");
mygrid.attachEvent("onRightClick", onButtonClick);
mygrid.setSkin("dhx_skyblue");
mygrid.loadXML("../common/gridH_03_context_menu.xml");
</script>