1

How can we clear/reset the selected item on a Radzen DropDown?

I did not use bind-Value to get the selected item.

Instead, I used Change() to get the selected object.

However, if I select one item on the DropDown and change the content of tempLocations, the selected item itself will not be cleared.

View:

<RadzenDropDown Name="Location" TValue="string" Data=@tempLocations Change=@(args => LocationChange(args))>
        <Template Context = "location">
            @($"{location.id}:{location.name}")   
        </Template>
    </RadzenDropDown>
AsM
  • 91
  • 1
  • 10
  • Is there any specific reason you do not want to bound a value to this dropdown? – maciek Dec 06 '22 at 13:23
  • Simply because I don't need to declare a class object (maybe also declare a temporary class only to store this DropDown item) and bind it. And, I just have to select the item. Then, `LocationChange()` will access the content of the selected item and do the rest. – AsM Dec 07 '22 at 03:19

1 Answers1

0

I guess there will be no solution expect using bind-Value.
Here is my updated coding:

<RadzenDropDown @bind-Value=@tempSelectedLocation Name="ALocation" Data=@tempLocations Change=@(args => LocationChange(args))>
                <Template Context = "location">
                    @($"{location.pressure} {location.name}")  
                </Template>
            </RadzenDropDown>

tempSelectedLocation is a class object.

AsM
  • 91
  • 1
  • 10