Get selected node in code behind stopped working after update

Hi,

Today I updated from version: 19.1.0.66 to version 19.2.0.48

But now I can no longer access selected nodes in code behind with this code

SfDiagram diagram = null!;

if (diagram.SelectedItems.Nodes != null && diagram.SelectedItems.Nodes.Count == 1)

     ShowNodeResult(diagram.SelectedItems.Nodes.Single());

The property " diagram.SelectedItems.Nodes" is allways null.


So how do I access the selected node with the new version of the diagram?

PS if I roll back the version it works again


3 Replies 1 reply marked as answer

AM Arunkumar Manoharan Syncfusion Team July 22, 2021 12:43 PM UTC

Hi Torben,   
We have created a sample on how to get the selected node. in this sample by onclick event we have added your code and taken out the selected item from the diagram. For more information, please refer to the sample link and code snippet. 
Code snippet: 
SfDiagram diagram = null!; 
 
public void onclick(MouseEventArgs args) 
    { 
        if (Diagram.SelectedItems.Nodes != null && Diagram.SelectedItems.Nodes.Count == 1) 
        { 
            int countt = Diagram.SelectedItems.Nodes.Count; 
        } 
    } 
 
Regards,  
Arun. 



TL Torben Laursen July 22, 2021 08:53 PM UTC

Thanks for the example.

I found the issue. It was a bug in my own code.

My code was loading a stored diagram in the "Created" event by awaiting a async function call.

When I changed it to a non sync function it works again.



Marked as answer

GG Gowtham Gunashekar Syncfusion Team July 23, 2021 12:33 PM UTC

Hi Torben,   
 
Thanks for your update. Please let us know whether you need any further assistance on this. 
 
 
Regards, 
Gowtham 


Loader.
Up arrow icon