Need to dynamically change ContextMenu items

I would like to dynamically change the content of the ContextMenu in a diagram depending on the selected element at the time. I've seen this is possible in the ContextMenu outside of a diagram, so I want to know if it's possible in this context as well. Any help is appreciated!


1 Reply

GG Gowtham Gunashekar Syncfusion Team August 23, 2021 12:05 PM UTC

 
Hi Remko, 
 
Yes, we can show and hide the context menu item based on the node selection in diagram. Please refer to the following sample for how to show/hide the context menu items based on the type of the selected node. In the sample we have used the contextMenuOpen event. Whenever we perform right click the contextMenuOpen event will trigger and it has the hiddenItems property in its argument, and we can push the item ids into the hiddenItems collection which we need to hide in the context menu. in sample we have add multiple items to the context menu, when perform right click on the BPMN event shape, its shows only two items and when perform right click on the BPMN task node only five items will show, and remaining items will hide and if we click on diagram the entire context menu will not show. These restrictions are added in the contextMenuOpen event . We have added the video link for your references.  
 
 
Regards 
Gowtham 
 


Loader.
Up arrow icon