Programmatically select Autocomplete options #1728
Replies: 2 comments
-
Yes, you can use the Example, adding this code in the existing default demo: https://fluentui-blazor.net/Autocomplete protected async override Task OnInitializedAsync()
{
var allCountries = await Data.GetCountriesAsync();
SelectedItems = new[]
{
allCountries.First(i => i.Code == "be"),
allCountries.First(i => i.Code == "fr"),
};
} What is your question? |
Beta Was this translation helpful? Give feedback.
0 replies
-
@dvoituron Thank you! That was the clue I needed. Entirely my mistake. I was persisting selected objects to localstorage, then deserializing and adding directly to |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What is the correct mechanism to pre-select options in Autocomplete from code?
I currently just provide a list of objects to
SelectedOptions
. Works as far as the Autocomplete UI is concerned but I'm seeing flakiness in select/unselect behavior. Wondering if I should instead call some Autocomplete method to select options as appropriate, but I'm not seeing aselect
method. Perhaps I'm going about this wrong...Beta Was this translation helpful? Give feedback.
All reactions