DHTMLX Grid : Column Context Menu

Hi,

I have used following to create the context menu for Column headers.



// Column Header Context Menu Creation : S

var colMenu = new dhtmlXContextMenuObject(‘120’, 0);

colMenu.setContextZone(libTableGrid.hdr,“header”); //attach context menu to grid header

colMenu.menu.loadXML("<%=path%>/xml/context/colMenuOptions.xml");

colMenu.setContextMenuHandler(colMenuClicked);

// Column Header Context Menu Creation : E



Do I need to attach it to the grid as I already have attached the context menu for the data part(CELL) ???





Now in colMenuClicked() which is handling the click event in menu, I want column id of that column header, How can I get it ???

Please help !!!

Do I need to attach it to the grid
Menu attached to the grid will be shown when any cell in data prart of grid has been clicked
If you want to use the same menu for header and data part of grid - using grid.enableContextMenu has sense, in other cases you need not any additional command.

>>I want column id of that column header, How can I get it
The context menu handler will return just ID of element , with which setContextZone was called ( “header” in your case )
The context menu was used against some HTML element , so it can’t provide info about in-grid structures.

Hi,
     Is there some way or what do I need to change in the corr JS file to get Column Id of column on which the context menu is created ?

The next may work in most cases

colMenu.setContextMenuHandler(colMenuClicked);
function colMenuClicked(menuId,zoneId,zoneObject){
var cell = mygrid.getFirstParentOfType(zoneObject,“TD”);
if (cell) alert("column index " + cell._cellIndex);
};

Hi,
    I used your mentioned code, but it is alerting undefined for column index.
    I slightly modified the code like ::

                            var cell = libTableGrid.getFirstParentOfType(zoneObject,“TD”);
                                        if (cell) alert("column index " + cell.cellIndex);
    then it is giving always 0 as column index. I want 0 for first column, 1 for second column and so on if I click on Context menu options of Column Header.
 
    Why this happens ?

Working sample sent by email.

Hi,
    I haven’t received the sent file, please re-send it. Thanks in Advance.

If you still have not receive email, please contact us directly at support@dhtmlx.com