We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

when I right-click for contextmenu, nodeselected gets fired

Hi,

I have a treeview and a context menu:

<ejs-treeview id="myTree" nodeSelected="onNodeSelect">
<ejs-contextmenu id="menu" target="#myTree" items='ViewData["menuItems"]' select="menuClick" beforeOpen="beforeOpen"></ejs-contextmenu>

Problem is: NodeSelected and ContextMenu events are firing together and I'm not able to show the ContextMenu.

In the NodeSelected, I want to load a page however when the contextmenu is clicked I want to show the menu.

What happens in my case is, when I right-click for contextmenunodeselected gets fired and hence a page is loaded instead of simply showing context menu.

Could you please let me know how I could handle this?

Thank you.

1 Reply

CI Christopher Issac Sunder K Syncfusion Team March 29, 2019 01:28 PM UTC

Hi John, 

Greetings from Syncfusion!! 

You can check whether you right click the node for showcasing the context menu by using following code snippet in the nodeSelected event of treeview and cancel the event while showing the context menu using right click. 

function onNodeSelect(args) { 
    if (event.which === 3 && event.button === 2) { 
        args.cancel = true; 
    } else { 
        alert("Node Selected"); 
    } 
} 


Please check the sample and get back to us if you need any further assistance. 

Thanks, 
Christo 


Loader.
Live Chat Icon For mobile
Up arrow icon