Hi there,
I am configuring the context menu on my grid using an xml file.
I then need to hide and show specific menu items based on the business logic. I do this by calling the function below on the “onBeforeContextMenu”
event of the grid. I followed the following logic as per your reference example :-
- Hide all the menu items using hideItem()
- Make specific items visible using showItem() on basis of business logic.
The issue that I am facing is that all the 3 items in menu appear on grid after exiting changeMenu() function.
Uncommenting alert statement in changeMenu() outputs as null. I am using IE6 and unfortunately I need to stick to it.
Please help.
Thanks,
Kamlesh
XML file format
JSP Code
//Menu intialization
var menu=new dhtmlXMenuObject();
menu.renderAsContextMenu();
menu.attachEvent("onClick", onMenuClick);
menu.loadXML("/fams/dhtmlx/context.xml");
//Tree Grid intialization
mygrid = new dhtmlXGridObject('gridbox');
//additional code related to mygrid
mygrid.enableContextMenu(menu);
mygrid.init();
mygrid.attachEvent("onBeforeContextMenu", changeMenu);
mygrid.enableDragAndDrop(false);
mygrid.enableLightMouseNavigation(true);
// At later point in code - on basis of users seletion on UI, following method is called to populate
// data in the Grid
function loadExpenseData(url){
mygrid.editStop(true);
mygrid.clearAll();
mygrid.loadXML(url,doAfterRefresh);
document.getElementById("gridbox").style.cursor = 'wait';
popupMessageBox("Loading...");
showStatus('Loading...');
mygrid.editStop(false);
}
function changeMenu(rowId, celInd, grid){
var str = mygrid.getUserData(rowId,“level”);
var arr = [“add”, “cpfw”,“paste”]; //cpfw - copy forward
for (var i = 0; i < arr.length; i++) {
menu.hideItem(arr[i]);
//alert(“isItemHidden “+menu.isItemHidden(arr[i]) );
}
var readOnly = mygrid.getUserData(””,“readonly”);
if( readOnly!=null && readOnly == “0”){
if(str!=null){
var level = str.split(’,’)[0];
if(level==‘R’) menu.showItem(“add”);
if(celInd >= getActualsMonth() && level==‘E’) menu.showItem(“cpfw”);
if(window.clipboardData.getData(“Text”)!=null && window.clipboardData.getData(“Text”).trim() !=""){
if(celInd >= getActualsMonth() && level==‘E’) menu.showItem(“paste”);
}
}
}else
return false;
return true;
}