Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by zoomsthru on Aug 27, 2009 14:31
open dhtmlx forum
Customised context menu

I would like to build a context menu for a tree. The contents of the context menu will depend on the tree node which has been selected and this requires some server-side computing. loadxml does not serve the purpose as the contents of the menu remain static. I tried to load an XML string using enableDynamicLoading but this does not display child components in the menu.

Is there any something which can be done to accomplish this task? Thanks in advance.
Answer posted by Alex (support) on Aug 28, 2009 01:59

There is onBeforeContextMenu it occurs before menu is shown. You can use it to hide/show item.

Please, see the sample in tree package:

dhtmlxTree/samples/context_menu/pro_menu.html

http://dhtmlx.com/docs/products/dhtmlxTree/samples/context_menu/pro_menu.html

Answer posted by zoomsthru on Aug 28, 2009 12:39
I did check out onBeforeContextMenu, but it seems I will need to know in advance which items I need to hide or display. I will not know the contents of the context menu without doing some computation on the server-side. I am effectively looking to do a loadXML after each right-click on a tree node.
Answer posted by Alex (support) on Aug 31, 2009 01:50

You can call loadXML from onBeforeContextMenu event:

tree.attachEvent("onBeforeContextMenu",function(itemId){
  menu.loadXML(.......);

  return true
})