Is it viable to update the dropdown tree based on selections made through an API?

Could we incorporate additional nodes as I make selections?


I've been able to retrieve the data linked to the node, but I'm now looking to display them in the dropdown tree beneath the previously chosen node.


1 Reply 1 reply marked as answer

JA Jafar Ali Shahulhameed Syncfusion Team March 21, 2024 07:44 AM UTC

Hi Gokala,


Based on the shared details we can understand that you are trying to utilize Syncfusion Blazor Dropdown Tree component. We have prepared the sample and achieved your requirement by using the Dropdown Tree component’s ValueChanging event. Kindly refer the code changes below,


<SfDropDownTree TItem="ProductCategory" TValue="int?" ID="list" Placeholder="Select a Category" PopupHeight="200px" ValueChanging="OnValueChanging">

    <DropDownTreeField TItem="ProductCategory" DataSource="@Categories" ID="Id" ParentID="ParentId" Text="Name" HasChildren="HasChild" Expanded="Expanded"></DropDownTreeField>

</SfDropDownTree>

 

 

public void OnValueChanging(DdtChangeEventArgs<int?> args)

{

    count++;

    ProductCategory product = Categories.Find(x => x.Id == args.CurrentValue);

    product.HasChild = true;

    Categories.Add(new() { Id = count, Name = "New Name " + count, ParentId = args.CurrentValue });

}


We have attached the sample for your reference,


Sample:  Attached as zip folder


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


Regards,

Jafar


Attachment: DropdownTree_Sample_1feb0b97.zip

Marked as answer
Loader.
Up arrow icon