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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

when I right-click for contextmenu, nodeselected gets fired

Thread ID:

Created:

Updated:

Platform:

Replies:

143593 Mar 28,2019 09:14 AM UTC Mar 29,2019 01:28 PM UTC ASP.NET Core - EJ 2 1
loading
Tags: TreeView
John Stephen Mangam
Asked On March 28, 2019 09:14 AM UTC

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.

Christopher Issac Sunder K [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;