Categories | Question details Back To List | ||||||||
context menu Header on Grid Hello There, I need to create a new Dhtmlx window on a right click of grid header which is inside a parentDhtmlx window. So that on right click of each header window is popped up. My code looks like function gridInit(rowId,celInd,grid) { dhxWins= new dhtmlXWindows(); dhxWins.setImagePath("../Common/Imgs/"); var win=dhxWins.createWindow("w1",10,10,320,240); dhxWins.window("w1").maximize(); mygrid= win.attachGrid(); menu = new dhtmlXMenuObject(); menu.setImagePath("/Common/Images"); menu.setIconsPath("/Common/MenuImgs"); menu.attachEvent("onClick",onButtonClick); mygrid.enableContextMenu(menu); mygrid.attachEvent("onBeforeContextMenu",onShowMenu); mygrid.hdr.id= "header"; menu.addContextZone("header"); } function onShowMenu(rowId,celInd,grid) { dhxWins= new dhtmlXWindows(); dhxWins.setImagePath("../Common/Imgs/"); var win=dhxWins.createWindow("w1",10,20,100,100); } I tried following the post http://www.dhtmlx.com/docs/products/kb/index.shtml?cat=search&page=1&q=5728&ssr=yes&s=context%20menu%20Header but in vain? Answer posted by Alex (support) on Apr 06, 2009 05:20 Hello, If you want to set context menu only for header the following methods must be commented: //mygrid.enableContextMenu(menu); In order to initialize menu as context you should use the following method: menu.renderAsContextMenu(); The full code is mygrid= win.attachGrid(); menu.renderAsContextMenu(); menu.loadXML(path_to_xml); Answer posted by Manhar on Apr 06, 2009 08:17 Now my code looks like this mygrid= win.attachGrid(); menu = new dhtmlXMenuObject(); menu.setImagePath("/Common/Images/"); menu.setIconsPath("/Common/MenuImgs/"); menu.attachEvent("onClick",onButtonClick); menu.renderAsContextMenu(); menu.loadXML("/Common/_context.xml"); //SET HEADER mygrid.setHeader(""); //SET COLUMN TYPE //SET COLUMN WIDTH mygrid.hdr.id= "header"; menu.addContextZone("header"); I have double checked the image and xml file path, which is being downloaded to browser, but still i am not able to see the right click context menu. My ultimate aim is to capture right click on grid headers and create a new Dhtmlx window on the click. Can that be alternatively achieved anyway? I have also attached the full code here for reference. Attachments (1)
Answer posted by Alex (support) on Apr 07, 2009 01:26 The header must have any cells. And moreover init() method is obligatory if you don't use xml initialization: ... grid.setHeader(" "); |