Hi there,
I am configuring the context menu on my grid using an xml file.
I then need to hide and show menu items based on the column index. I do this by calling the function below on the “onBeforeContextMenu” event of the grid. The function executes as expected, it even changes the isHidden status of the menu items correctly. The problem however is that the menu that is shown after exiting this function is the original menu loaded via XML and does not reflect the updates made by the “onShowMenu” function below.
dhxGrid.attachEvent("onBeforeContextMenu", onShowMenu);
function onShowMenu(rowId, celInd, grid) {
/* hide show items based on context */
var arr = ["info", "olap", "drill_up_to", "drill_down", "drill_into", "drill_up", "chart","top10", "bottom10","donut", "gauge"];
for (var i = 0; i < arr.length; i++) {
cmenuGrid.hideItem(arr[i]);
}
var dateIdx = dhxGrid.getColIndexById("DATETIME");
switch (true) {
case (celInd < dateIdx-1):
cmenuGrid.showItem("olap");
cmenuGrid.showItem("drill_up_to");
break;
case (celInd == dateIdx-1):
cmenuGrid.showItem("olap");
cmenuGrid.showItem("drill_down");
break;
case (celInd == dateIdx):
cmenuGrid.showItem("olap");
cmenuGrid.showItem("drill_up");
cmenuGrid.showItem("drill_down");
break;
case (celInd > dateIdx):
cmenuGrid.showItem("info");
cmenuGrid.showItem("olap");
cmenuGrid.showItem("drill_into");
cmenuGrid.showItem("chart");
cmenuGrid.showItem("top10");
cmenuGrid.showItem("bottom10");
cmenuGrid.showItem("donut");
cmenuGrid.showItem("gauge");
cmenuGrid.showItem("trend");
break;
}
return true;
}
I have been stuck on this for several hours. Please help if you can!
Many thanks,
Rose