Hi Greg Keogh,
Greetings from Syncfusion support.
TreeView has no two-way binding for the data source property in our previous versions(release version before 18.3.35). So, we suggested to use AddNodes method for adding nodes in TreeView dynamically.
We have provided a two-way binding support for data source property from Syncfusion.Blazor NuGet version 18.3.35 as part of optimizing the functionalities and performance of the component. So, there is no need to use AddNodes and RemoveNodes properties in TreeView. Due to this reason, we have deprecated the AddNodes/RemoveNodes method from release version 18.3.35.
Now, when you directly update the data source to add/remove tree nodes in TreeView. This changes will automatically reflect in UI of TreeView component.
Please, refer to the below release notes for breaking changes of TreeView component on the version 18.3.35.
Please refer to the code snippet of the above explained solution.
|
<SfButton Content="ADD_Node" OnClick="Add_Node"></SfButton>
<SfButton Content="Remove_Node" OnClick="Remove_Node"></SfButton>
<SfTreeView @ref="tree" TValue="MailItem">
<TreeViewFieldsSettings TValue="MailItem" Id="Id" DataSource="@MyFolder" Text="FolderName" ParentID="ParentId" HasChildren="HasSubFolders" Expanded="Expanded"></TreeViewFieldsSettings>
</SfTreeView>
public void Add_Node()
{
MyFolder.Add(new MailItem
{
Id = "7",
ParentId = "2",
FolderName = "Music"
});
} public void Remove_Node()
{
List<MailItem> removeNode = tree.GetTreeData("3");
MyFolder.Remove(removeNode.ElementAt(0));
} |
We have attached the sample with above solution for your reference. Please, download the samples from the following link.
Refer to the below link to know more about the TreeView component.
Please let us know, if you need any further assistance.
Regards,
Sowmiya.P