TreeView load and select nodes

Hello,

i am using the latest version of syncfusion blazor 19.4.0.38.

I am using the treeview as a navigation for a catalogue.

In the OnInitializeAsync event i load the first level of the treeview and in the onexpand event i load the children of the expanded node.

To let my customer deep link to a specific topic in the catalogue i change the uri using the navigationmanager.

The url looks like https://server/Europe/Germany/Bavaria/Munich

In the OnInitializeAsync i parse the uri and split the path to my catalogue nodes. In the above case i read the node "Europe" from the database and add it to the datasource of the treeview and so on.

After reading the last item in the path, in this case "Munich" i want to select this node and want to fire the OnNodeSelect event. The node is getting selected but the OnNodeSelect event is not getting fired.

Is this the correct way to load data and iterate throu the path of the uri to load nodes and select a node ?


Thanks

Ulrich


5 Replies

IL Indhumathy Loganathan Syncfusion Team December 27, 2021 11:52 AM UTC

Hi Ulrich, 
 
Greetings from Syncfusion support. 
 
We understood that you are loading the parent nodes initially and loading the child nodes while expanding the node. We have handled similar scenario in the below demo. 
 
 
 
Here the NodeSelecting event triggers properly in the above sample. Kindly check whether you are trying the same approach. For further assistance, share the complete code snippet and Syncfusion package version used in your sample. Else replicate the issue in the shared sample. These details would help us to serve you better. 
 
Regards, 
Indhumathy L 



UL Ulrich December 27, 2021 03:32 PM UTC

Hello  Indhumathy ,


thank you for your post.

I have tested the behaviour with your source code and it does not work.

I have slightly modified the sourcecode you are using.

- Added a selected property to FileData

- Setting the Selected of the 2nd record in the onintialized event to true.

After run the 2nd entry in the treeview is highlieghted as selected but the event is not getting triggered.

Find attached the file i have modified.

Thanks for your help


Ulrich



Attachment: Index_3c726e05.zip


IL Indhumathy Loganathan Syncfusion Team December 28, 2021 12:56 PM UTC

Hi Ulrich, 
 
TreeView's NodeSelecting event will be triggered while selecting or unselecting nodes with UI interaction or dynamic node selection. But you have enabled the Selected property within the TreeView datasource on initial rendering, which will not trigger the NodeSelecting event. 
 
So, we'd like to confirm your exact use case. 
 
Do you want to retrieve the selected node details on initial rendering? If so, we have the SelectedNodes property in TreeView which will return the selected node ID values.  
Or else, do you want to get the complete node data of selected nodes? If that’s the case, please elaborate on your requirements, so that we can assist you promptly. 
 
Regards,   
Indhumathy L 



UL Ulrich January 2, 2022 09:53 AM UTC

Hello,

after parsing the URI i want to select the node and run the code in the onnodeselect procedure.

I have split the code and it works as expected.

Thanks


Ulrich



KR Keerthana Rajendran Syncfusion Team January 3, 2022 05:27 AM UTC

Hi Ulrich, 
 
Thanks for the update. We are glad to hear that the issue is resolved. Please get back to us if you need any further assistance. 
 
Regards, 
Keerthana R. 


Loader.
Up arrow icon