TreeGrid header, right click menu?

I was just wondering if anyone has worked out how to add a right click custom menu to the header or footer of a tree grid.

I currently have mygrid.enableContextMenu(menu);
However I have no idea how to add a custom menu to anywhere outside of my actual grid items.
I have tried to add a context menu to “xhdr” with no success


You can add id for the grid header and use it as dhtmlxMenu context zone

Hi Olga,
Thanks for getting back to me.
I have added :

this.hdrBox.setAttribute('id', 'xhdr');

after where the class is added for xhdr (this.hdrBox.className=“xhdr”:wink:

and the following code in the initTreeGrid :

hdr_menu = new dhtmlXMenuObject("xhdr"); hdr_menu.renderAsContextMenu(); hdr_menu.addNewChild(hdr_menu.topId, 0, "new", "New”, false, "new.gif");
however this isn’t working.
Is there something I am missing?
Thanks again

Check the attached sample, it adds context menu to the header of grid. (122 KB)

Hi Stanislav,
Fantastic thank you. I was missing the = "header";

I also added a menu to my footer :smiley: = "footer";

Thanks again


can i add menu for tree like this without using tree.enableContextMenu();

u me