Disable menuItem in ContextMenu

I added a custom menu in my treegrid.
I would like open the customContextMenu with some menuItem disabled according to some condition. The disabled menuItem must not be clickable.
What is the proper way to do this?

Thank you

1 Reply

PE Punniyamoorthi Elangovan Syncfusion Team April 20, 2018 01:30 PM UTC

Hi Cosimo, 
Thank you for contacting Syncfusion support 
We have analyzed your requirement. We can disable the custom menu item by using disable property. Please refer the below code snippet. 
<script type="text/javascript"> 
function contextMenuOpen(args) { 
var contextMenuItems = [{ 
                   headerText: "Top", 
                   eventHandler: customMenuAddHandler, 
                   menuId: "Top", 
                   parentMenuId: "Add", 
                   iconClass: "e-topIcon", 
                   disable: true 
 
               }, { 
                   headerText: "Bottom", 
                   menuId: "Bottom", 
                   parentMenuId: "Add", 
                   eventHandler: customMenuAddHandler, 
                   iconClass: "e-bottomIcon", 
                   disable: true 
               }, 
             ]; 
             args.contextMenuItems.push.apply(args.contextMenuItems, contextMenuItems); 
           } 
       } 
</script> 
We have prepared the JS Playground for your reference, please find the sample link below 
Please let us know if you require further assistance on this. 
Regards, 
Punniyamoorthi

Loader.
Up arrow icon