Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by pyt on Oct 14, 2009 03:33
open dhtmlx forum
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
Answer posted by Alex (support) on Oct 14, 2009 05:10

Hello, 

please provide complete demo to recreate the issue.

Answer posted on Oct 14, 2009 06:33
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
   
Answer posted by Alex (support) on Oct 15, 2009 02:19

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 ( http://dhtmlx.com/docs/products/dhtmlxGrid/samples/03_context_menu/04_pro_context_dynamic.html )

Answer posted on Oct 15, 2009 09:12
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 
Answer posted by Alex (support) on Oct 16, 2009 01:50

Hello, 

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