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
dhtmlx.com/docs/products/kb/ … u%20Header but in vain?
Hello,
If you want to set context menu only for header the following methods must be commented:
//mygrid.enableContextMenu(menu);
//mygrid.attachEvent(“onBeforeContextMenu”,onShowMenu);
In order to initialize menu as context you should use the following method:
menu.renderAsContextMenu();
The full code is
mygrid= win.attachGrid();
menu = new dhtmlXMenuObject();
menu.setImagePath("/Common/Images/");
menu.setIconsPath("/Common/MenuImgs/");
menu.attachEvent(“onClick”,onButtonClick);
menu.renderAsContextMenu();
menu.loadXML(path_to_xml);
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.
Index.vm (22.6 KB)
The header must have any cells. And moreover init() method is obligatory if you don’t use xml initialization:
…
grid.setHeader(" ");
grid.setInitWidthsP(“100”);
grid.init()
grid.hdr.id="header"
menu.addContextZone(“header”);