Expand to node when page is loaded.

How do you expand to a particular node when the page is rendered? 



5 Replies 1 reply marked as answer

MK Muthukrishnan Kandasamy Syncfusion Team July 27, 2020 07:34 AM UTC

 
Hi Wright, 
 
Thanks for contacting Syncfusion support. 
 
We have validated your requirements in Syncfusion Blazor TreeView component. We can expand the tree nodes on initial rendering by using the Expanded field attribute. We can set the true value for the particular node expanded attribute. Please refer the below code block. 
 
List<MailItem> Folder1 = new List<MailItem>(); 
        MyFolder.Add(new MailItem 
        { 
            Id = "01", 
            FolderName = "Inbox", 
            SubFolders = Folder1, 
            Expanded = true 
        }); 
 
We have prepared sample for your convenience, which can be downloaded from the below link. 
 
 
Description 
Link 
Getting started 
CRUD operation in local data 
API reference 
Live demo 
 
 
Please let us know, if you need any further assistance. 
 
Regards, 
Muthukrishnan K 
 



DW D Wright July 27, 2020 04:53 PM UTC

How would i expand it if i dont have control over the object coming back?  


SP Sowmiya Padmanaban Syncfusion Team July 28, 2020 11:11 AM UTC

Hi D Wright,  
 
In TreeView component, we have ExpandAll method. When passing the ID value of node as argument for ExpandAll method will expand the corresponding node with that ID and you can perform this operation in on DataBound event. If you don’t pass any ID to the expandAll method, it expands the entire TreeView nodes which has child tree nodes. 
 
Refer the below code snippet. 
 
<SfTreeView TValue="MailItem" @ref="treeView"> 
    <TreeViewEvents TValue="MailItem" DataBound="dataBound"></TreeViewEvents> 
    <TreeViewFieldsSettings TValue="MailItem" Id="Id" Text="FolderName" Child="@Child" Selected="Selected" DataSource="@MyFolder" Expanded="Expanded"></TreeViewFieldsSettings> 
</SfTreeView> 
  public void dataBound(Syncfusion.Blazor.Navigations.DataBoundEventArgs<MailItem> args) 
    { 
        this.treeView.ExpandAll(new string[] { "01" , "01-01"}); 
    } 
 
Refer the sample link below. 
 
 
Please let us know, if you need any further assistance. 
 
Regards,  
Sowmiya.P 


Marked as answer

DW D Wright July 28, 2020 02:21 PM UTC

That worked!  thanks for your help


SP Sowmiya Padmanaban Syncfusion Team July 29, 2020 04:27 AM UTC

Hi D Wright,  
  
Most Welcome. We are happy to hear that your problem has been resolved. Please contact us, if you need any help from us. 
  
Regards,  
Sowmiya.P 


Loader.
Up arrow icon