Replies: 1 comment 1 reply
-
Yes, the whole idea of an AutoComplete is to have a list of items. The If you do not want the user to edit the value, you should probably just use a Badge or something like that. I did not go in to deep, but don't completely understand why you'd want to use an autocomplete, |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm having trouble correctly binding the value of an autocomplete field inside of a Data Grid to a value in that row.
So I have a custom reusable Autocomplete component containing this:
Where the AutocompleteOption is a class simply containing an id and a label. The CustomAutocomplete has this code-behind:
The idea here is that the autocomplete should be limited to one item, but FluentAutocomplete seemingly needs a list of items. Which is why I added that internal mapping to the first item of the list, and exposed only a single AutocompleOption to the parent component.
I have a Data Grid containing a list of ingredients for a recipe, I'll show the Unit column since it's the simplest. The unit of the item for a row It is bound to the AutocompleOption of the autocomplete.
And the unit class can itself map the incoming autocomplete values like this:
The goal here is simply that the autocomplete should display the name (and save the id) of the unit for each row, including any preexisting values in the model, and when I select another value the unit in the model should be updated to reflect that change.
And the binding seems to work since the model values are loaded into the autocomplete when I load the page. But I cannot remove or change the text in the autocomplete. It's behaving like a read-only field. Is this because the model values are bound to the text field and keep overriding it?
It's my first time with both Blazor and Fluent UI so feel free to suggest any other improvements I can make.
Beta Was this translation helpful? Give feedback.
All reactions