Context Menu in dhtmlxFolders

Hello

I can’t get context menu to work in dhtmlxFolders have you got any examples

This is what I am trying


myFolders = new dhtmlxFolders("folders");
myFolders.setItemType("ficon");
myFolders.setUserData("icons_src_dir", "/media/dhtmlx/imgs/folders/");
myFolders.loadXML("/path/to/xml_source.xml","/path_to/itemtype_visualization/xsl_file.xsl");


 menu = new dhtmlXMenuObject();
 menu.renderAsContextMenu();
 menu.setIconsPath("../common/imgs/");
 menu.addNewChild(menu.topId, 0, "open", "Open", false, "open.gif");
            
 myFolders.enableContextMenu(menu);

Many Thanks

Tom

There is no native integration between folders and menu, you can try to add the next line to the your code

 myFolders._ctmndx = menu; 

No it did not work with that line of code

are you planning to add this feature ?

We are going to release DataView component. It provides all Folders features and even more, much more.
Here are the details:
dhtmlx.com/blog/?p=279

We’ll add the onBeforeContextMenu in the official version of DataView (it will be released in several weeks). Using this event you will be able to show context menu.

Hallo,
is there any onBeforeContextMenu function? unfortunely I can’t find any of.
:unamused:

Hello Rayden,

did you ask about dataview ?

dataview.attachEvent(“onBeforeContextMenu”, function(itemId,e){
/your code here/
})

Thank you for your quick reply dear Alexandra.

I have now this issue:
I can not attach the ContextMenu to the selected DataView-Item.
I see (on the Firebug-Console) that the ContextMenu-File is fetched, but no visual appearance.

My Example-Test-Code:
var dataview = new dhtmlXDataView({
container: “idCustomerListContent”,
type: { template: “#title##author# #lprice#”, height: 35 }
});

dataview.load(“books.xml”); /* <-- default demo file in dhtmlxDataView */
dataview.attachEvent(“onBeforeContextMenu”, function(itemId,e){
var menu = new dhtmlXMenuObject();
menu.setIconsPath("…/…/…/lib/img/ico/");
menu.renderAsContextMenu();
menu.loadXML(“xml.ContextCustomer.php”);
});

Thank you

You need to call showContextMenu method to display menu is a certain position. For example:

[code]var menu = new dhtmlXMenuObject();
menu.setIconsPath("…/…/…/lib/img/ico/");
menu.renderAsContextMenu();
menu.loadXML(“xml.ContextCustomer.php”);

dataview.attachEvent(“onBeforeContextMenu”, function(itemId,e){
var x = e.clientX;
var y = e.clientY;
menu.showContextMenu(x,y);
return false;
});[/code]

Also I forgot to mention that onBeforeContextMenu must return false to block browser context menu.