Hi Chris,
Greetings from Syncfusion support.
We understood that your requirement is to hide the SFTreeView without clearing its data source. We can achieve your requirement using DisableNodes method in Treeview component.
DisableNodes method will disable the collection of tree nodes when passing the ID of nodes or node elements as parameter in string array type.
We have prepared a sample solution in which entire TreeView will hide on button click. To achieve this requirement, we have set display none for e-disable which will added to all the tree nodes when DisableNodes method is executed.
|
@using Syncfusion.Blazor.Navigations
<SfTreeView TValue="MailItem" @ref="TreeInstance">
<TreeViewFieldsSettings TValue="MailItem" Id="Id" DataSource="@MyFolder" Text="FolderName" ParentID="ParentId" HasChildren="HasSubFolders" Expanded="Expanded"></TreeViewFieldsSettings>
</SfTreeView>
<button class="btn btn-primary" @onclick="HideTreeView">
Hide TreeView
</button>
<style>
.e-treeview .e-disable {
display: none;
}
</style>
@code{
SfTreeView<MailItem> TreeInstance;
private void HideTreeView(MouseEventArgs e)
{
foreach (var item in TreeInstance.GetTreeData())
{
TreeInstance.DisableNodes(new string[] { item.Id });
}
}
} |
Please, find the sample with the above suggested solution for your reference.
Please, let us know if you need any further assistance.
Regards,
Shameer Ali Baig S.