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.
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.
@manu did you submit a pull request? i would like to add this functionality.
I would like to +1 this. A string is pretty worthless when using a component like this. Even If I'm navigating to a detail page, I'll need a unique ID of sorts, not the readable string value.
Except I don't want to display all the data when the user clicks the dropdown. I only want to display possible selections when the user begins to type. Is there a way to not show the "list" in a dropdown list until the user begins to type? The dropdown control is not the proper control for this.
I`m at the same point. Implementing the Autocomplete and I can´t use it, because I need to get back the object or the unique ID which ist different to the TextProperty in which I search.
Searching in customer.Name but returning to the bind-value customer.ID
Like this is quite useless because two customers can have the same name.
@fabius916 use the DropDown component