Context menu for specific column
In example below context menu is available for the first column only.
In example below context menu is available for the first column only.
<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxgrid.css"> <link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxgrid_dhx_skyblue.css"> <link rel="stylesheet" type="text/css" href="../../../dhtmlxMenu/codebase/skins/dhtmlxmenu_dhx_skyblue.css"> <script src="../../codebase/dhtmlxcommon.js"></script> <script src="../../codebase/dhtmlxgrid.js"></script> <script src="../../codebase/dhtmlxgridcell.js"></script> <script src="../../codebase/excells/dhtmlxgrid_excell_link.js"></script> <script language="JavaScript" src="../../../dhtmlxMenu/codebase/dhtmlxmenu.js"></script> <table width="100%" border="0"> <tr> <td> <div id="gridbox" style="width:100%;height:270px;background-color:white;"></div> </td> </tr> </table> <script></script>function onButtonClick(menuitemId, type) { var data = mygrid.contextID.split("_"); //rowId_colInd; mygrid.setRowTextStyle(data[0], "color:" + menuitemId.split("_")[1]); return true; } function my_pre_func(rowId, celInd, grid) { if (celInd == 1) return false; return true; } menu = new dhtmlXMenuObject(); menu.setIconsPath("../common/images/"); menu.renderAsContextMenu(); menu.attachEvent("onClick", onButtonClick); menu.loadXML("../common/_context.xml"); mygrid = new dhtmlXGridObject('gridbox'); mygrid.setImagePath("../../codebase/imgs/"); mygrid.setSkin("dhx_skyblue"); mygrid.setHeader("Author,Title"); mygrid.setInitWidths("250,250"); mygrid.enableAutoWidth(true); mygrid.setColAlign("left,left"); mygrid.setColTypes("ro,link"); mygrid.setColSorting("str,str"); mygrid.enableContextMenu(menu); mygrid.attachEvent("onBeforeContextMenu", my_pre_func); mygrid.init(); mygrid.loadXML("../common/grid_links.xml");