Autocomplete - Get Object in Data List

Just like the autocomplete demo, I have an autocomplete with data comprised of a set of objects. However, unlike the demo, where just the string typed into the autocomplete is returned upon selection, I need to get the whole object. (Using the demo as an example, I would like to get the whole Customer object and not just the company name.) If I were using a dropdown or one of the other controls, I would just set the value property or bind the value to a selected object, but neither of these seem to work with the autocomplete component (no value property and get casting errors when I bind-value/bind-SelectedItem to an object).

Is there a way to get the whole object while using autocomplete, or is doing so beyond the scope of the component?

Thanks in advance for any assistance you can provide me on this issue.

1 Like

Indeed the Autocomplete provides only the value of the property specified via TextProperty. It does not currently provide the "whole" object. You can use the DropDown instead with filtering enabled.

I don't understand why you don't add a SelectedItem property (and maybe an IdProperty) to make the control a lot more usable. There are code systems where the displayed values are similar but the associated identifiers are not, so having only the selected displayed text is useless.

It is a very simple cange, create a property of type object called SelectedItem, and in System.Threading.Tasks.Task SelectItem(object item), add this as the first line:

SelectedItem = item;

If you want I can submit a pull request.