Dynamic context menu

Hi,



i’m trying to load an xml string for contextmenu via “enableDynamicLoading”. I call enableDynamicLoading from “onBeforeContextMenu” event. By first call it works correct, but in another calls the contextmenu shows the first content, althogh the xml string is changed.

Can you help me?



Thanks in advance!

pyt


Hello,


please provide complete demo to recreate the issue.

Hi,
i use the following codes:

    menu = new dhtmlXMenuObject();
    menu.setIconsPath(“images/”);
    menu.renderAsContextMenu();
    mygrid = new dhtmlXGridObject(‘gridbox’);
    mygrid.setImagePath(“codebase/imgs/”);
    mygrid.setHeader(“Author,Title”);
    mygrid.setInitWidths(“250,250”);
    mygrid.enableAutoWidth(true,true);
    mygrid.setColAlign(“left,left”);
    mygrid.setColTypes(“ro,ro”);
    mygrid.enableContextMenu(menu);
    mygrid.init();
    mygrid.loadXML(“grid_links.xml”);
    mygrid.attachEvent(“onBeforeContextMenu”,function(rowId,cellInd,grid) {
        var rowInd = grid.getRowIndex(rowId);
        if(cellInd == 0){
            if(rowInd%2==0)
                menu.enableDynamicLoading("_context1.xml");
            else if(rowInd%2==1)
               menu.enableDynamicLoading("_context2.xml");
        return true;
    }
    else
        return false;
    });
    mygrid.setSkin(“dhx_skyblue”)


and i have by the first rightclick no contextmenu.

Thanks in advance!
pyt
   


Hello,


this approach can not be used to show different context menus for rows. Please, try to use approach from the following sample in grid package:


dhtmlxGrid/samples/03_context_menu/04_pro_context_dynamic.html ( dhtmlx.com/docs/products/dhtmlxG … namic.html )

Hi,


in practice are my codes more complicated as my sample. The cell value defines the xml contents for contextmenu.
Can i use anyway enableDynamicLoading?

Thanks,
pyt


Hello,


there is no way to use different xml sources for one context menu.