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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Select Fired After BeforeOpen ContextMenu

Thread ID:

Created:

Updated:

Platform:

Replies:

146855 Aug 22,2019 05:24 PM UTC Aug 27,2019 09:39 AM UTC Angular - EJ 2 5
loading
Tags: Treeview
frederik
Asked On August 22, 2019 05:24 PM UTC

I used the how-to for a context menu in a tree view:

The problem I am facing is that the select event is fired after the context menu beforeopen one, so that I get null on the first call, and the previously selected node on subsequent right-clicks.

Am I missing something obvious?

Many thanks

My code 

<ejs-treeview #filesTree id='filesTree' [fields]='field' (nodeDragStop)="onDragStopped($event)" (nodeDragging)="onDragging($event)" (nodeSelected)='nodeSelected($event)'
[allowEditing]='canChange' (nodeEdited)='onNodeEdited($event)'
(nodeDropped)="onNodeDropped($event)" allowMultiSelection=false allowDragAndDrop=true></ejs-treeview>
<!-- -->
</div>
<ejs-contextmenu #fileContextMenu id='fileContextMenu' target='#filesTree' [items]='menuItems' (select)='menuclick($event)' (beforeOpen)='beforeopen($event)' ></ejs-contextmenu>

Narayanasamy Panneer Selvam [Syncfusion]
Replied On August 25, 2019 03:07 AM UTC

Hi Frederik, 
 
Greetings from Syncfusion support. 
 
We have validated your query and have prepared a sample based on the reported scenario. But we could not able to reproduce your issue at our end.  
Video reference: Output 
If the sample takes more time to load, then please run it in an incognito window. 
If still the reported issue is persisting at your end, Kindly modify the shared sample to reproduce the reported issue. It will be more helpful to assist you better. 
 
Regards, 
Narayanasamy P. 


frederik
Replied On August 26, 2019 07:13 AM UTC

The issue might be with self-referential data. I've edited the sample to reproduce the error.


The first right-click will show 'undefined' selected item. Clicking outside of the tree and then right-click again will keep on showing undefined. Selecting one, and then and then right-clicking another will show the id of the previously selected one.


Many thanks

Ashokkumar Balasubramanian [Syncfusion]
Replied On August 26, 2019 11:25 AM UTC

Hi Frederik, 
 
We have checked the reported issue and it was due to in some cases the beforeOpen event gets triggered even before the SelectedNode value gets initialized. So, you can use the following code snippet to get the target tree node in the beforeOpen event of the context menu
 
if ((args.event.target as any).closest('li')) { 
        this.targetNodeId = (args.event.target as any).closest('li').getAttribute("data-uid"); 
    } 
 
 
Please check the above sample and get back to us if you need any further assistance. 
 
Regards, 
Ashokkumar B. 


frederik
Replied On August 27, 2019 06:03 AM UTC

Thank you - this should do the trick

Ashokkumar Balasubramanian [Syncfusion]
Replied On August 27, 2019 09:39 AM UTC

Hi Frederik, 
 
Most Welcome. 
 
Please let us know, if you need any further assistance. 
 
Regards, 
Ashokkumar B. 


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

Live Chat Icon For mobile
Live Chat Icon