Node selection event

I've just started using the Blazor SfTreeView today, but I must seriously misunderstand how to use the component, because I can't find any kind of event to tell me when a node is selected. No videos or samples I can find mention how an application is supposed to respond to tree selections. Am I wrong to assume that some sort of Selected event is a normal usage pattern?

The component's API documentation doesn't provide any clues or examples either. I tried binding the SelectedNodes property to a string[], but it's never accessed.

Can someone point me in the right direction please?

Thanks, Greg

4 Replies

UN Unknown August 24, 2020 12:27 AM UTC

I eventually found the answer. I ran a search for "SfTreeView" through the 1549 .razor files in the C:\Users\Public\Documents\Syncfusion\Blazor folder. Luckily, I noticed one of the components used the <TreeViewEvents> element, which of course answers my question. Only 3 of the files contained that element.

Working backwards I went looking for <TreeViewEvents> to try and figure out why I never noticed it before. I found it mentioned in two of the documentation articles, one on using the context menu and the other on customising an accordion view. Both of those articles are currently of no interest to me, so I guess I just glanced at them and skipped over them. I conclude that I missed that vital event element because I did not methodically read all of the How To articles, just the ones I needed.

The tree view sample code concentrates on customising the appearance of the component. It took me hours of work to discover how to simply wire-up an event, so I think a How To article on that topic would be a good addition.

Thanks, Greg


SP Sowmiya Padmanaban Syncfusion Team August 24, 2020 11:27 AM UTC

Hi Greg Keogh, 
 
Sorry for the inconvenience. 
 
Yes, you can add the TreeView events using TreeViewEvents tag. Refer to the below link to know more about the TreeView events. 
 
 
For your reference, we have prepared a simple sample for TreeView select event. 
 
<SfTreeView TValue="MailItem" @ref="tree"> 
            <TreeViewEvents TValue="MailItem" NodeSelected="nodeSelect"></TreeViewEvents> 
            <TreeViewFieldsSettings TValue="MailItem" Id="Id" DataSource="@MyFolder" Text="FolderName" ParentID="ParentId" HasChildren="HasSubFolders" Expanded="Expanded"></TreeViewFieldsSettings> 
        </SfTreeView> 
  public void nodeSelect(NodeSelectEventArgs args) 
    { 
       var Node_Id = args.NodeData.Id; 
    } 
 
 
 
We will include this as a separate topic in our documentation on upcoming releases. 
 
To know more about the TreeView component, refer the below links. 
 
 
 
 
Please let us know, if you need any further assistance. 
 
Regards,  
Sowmiya.P 



BA BAx March 25, 2021 03:26 PM UTC

I second Greg on this one. The documentation is still poor and the links provided in this answer are mostly broken.


KR Keerthana Rajendran Syncfusion Team March 26, 2021 06:40 AM UTC

Hi Alessio, 
 
Sorry for the inconvenience.  
 
This is due to technical issues and we will resolve this. Please find the below API link for TreeView component.  
 
 
Rest of the links mentioned in previous update are working fine.  
 
Regards, 
Keerthana.  


Loader.
Up arrow icon