Selected node route generation not working correctly

I am trying to generate the node route but it is not being generated correctly. I'm using this post metodo https://blazor.syncfusion.com/documentation/treeview/node-selection#get-path-of-selected-node

Image_8359_1714778633400



I am generating the tree dynamically but when the ParentId is established the node stays loading, 

For now I only left the property Child="@("Child")"

Another question: is there any way to add some other extra property to each node? I tried to add it but when selecting it it does not bring the property




1 Reply 1 reply marked as answer

JA Jafar Ali Shahulhameed Syncfusion Team May 6, 2024 10:27 AM UTC

Hi Bulmaro,


We have prepared a sample to meet your requirements by making the necessary changes in the referred sample. Kindly check the code changes below,


[Query: 1 – Route generation]


[Index.razor]

 

@{

    string path = "";

    for (int i = ParentIdArray.Length - 1; i >= 0; i--)

    {

        path += ParentTextArray[i];

        if (i > 0)

        {

            path += "/";

        }

    }

}

<p>@path</p>

 

public void NodeSelected(NodeSelectEventArgs args)

{

 

    List<string> IdList = new List<string>();

    List<string> TextList = new List<string>();

    IdList.Add(args.NodeData.Id);

    TextList.Add(args.NodeData.Text);

   …

}



[Query: 2 – Get the additional properties of nodes]


<SfTreeView TValue="MusicAlbum" AllowMultiSelection="true" @ref="tree" @bind-SelectedNodes="SelectedNodes">

    <TreeViewEvents TValue="MusicAlbum" NodeSelected="NodeSelected"></TreeViewEvents>

</SfTreeView>

 

public void NodeSelected(NodeSelectEventArgs args)

{

    …

    var TreeData = tree.GetTreeData();

}


We have attached the sample for your reference,


Sample: Attached as zip file.


Kindly try out the shared details and get back to us if you need further assistance.


Regards,

Jafar


Attachment: Blazor_TreeView_86a2a618.zip

Marked as answer
Loader.
Up arrow icon