Context menu for specific column
In example below context menu is available for the first column only.
</> Source
<!DOCTYPE html>
<!--pro-->
<html>
<head>
<title>Context menu for specific column</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<link rel="stylesheet" type="text/css" href="../../../codebase/fonts/font_roboto/roboto.css"/>
<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlx.css"/>
<script src="../../../codebase/dhtmlx.js"></script>
<script>
var myGrid, myMenu;
function doOnLoad(){
myMenu = new dhtmlXMenuObject();
myMenu.setIconsPath("../common/images/");
myMenu.renderAsContextMenu();
myMenu.attachEvent("onClick",onButtonClick);
myMenu.loadStruct("../common/_context.xml");
myGrid = new dhtmlXGridObject('gridbox');
myGrid.setImagePath("../../../codebase/imgs/");
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(myMenu);
myGrid.attachEvent("onBeforeContextMenu",my_pre_func);
myGrid.init();
myGrid.load("../common/grid_links.xml");
}
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;
}
</script>
</head>
<body onload="doOnLoad()" onResize="return true;" oncontextmenu="return false;" >
<h1>Context menu for specific column</h1>
<p>In example below context menu is available for the first column only.</p>
<table width="100%" border="0">
<tr>
<td>
<div id="gridbox" style="width:100%;height:332px;background-color:white;"></div>
</td>
</tr>
</table>
</body>
</html>
Documentation
Check documentation to learn how to use the components and easily implement them in your applications.