How to clear or reset the selected nodes in treeview?

Need to clear selected node in treeview.

1 Reply 1 reply marked as answer

KR Keerthana Rajendran Syncfusion Team September 11, 2020 08:07 AM UTC

Hi Richy, 
 
Thanks for contacting Syncfusion support.  
 
You can clear the array variable mapped for SelectedNodes property to clear the selectedNode in TreeView. Refer to the following code 
 
<SfButton Content="Clear Selected node" OnClick="Clear"></SfButton> 
<SfTreeView @ref="tree" TValue="SideBarItem" SelectedNodes="@selectedNodes" AllowMultiSelection="true"> 
    <TreeViewFieldsSettings TValue="SideBarItem" Id="ID" DataSource="@MyFolder" Text="Text" ParentID="ParentId" HasChildren="HasSubFolders" Expanded="expanded"></TreeViewFieldsSettings> 
</SfTreeView> 
@code{ 
    public string[] selectedNodes { get; set; } = new string[] { "1" }; 
    public void Clear() 
    { 
        selectedNodes = new string[] { }; 
    } 
} 
 
We have attached a sample for reference in the following link. 
 
 
Note: This will clear the selected node only once. We have already logged a bug report for updating selectedNodes dynamically which will be included in Volume 3, 2020 release. You can track the status through the below feedback link 
 
 
To more details on TreeView, refer to the following links 
 
 
 
Please let us know, if you need further assistance.  
 
Regards, 
Keerthana.  


Marked as answer
Loader.
Up arrow icon