It would be nice to have access to a valueChange event in the autocomplete similar to the other dropdowns. This way when binding against arrays of complex objects, we could receive the whole object selected instead of the single value property out of it.
Hi,
We are closing this feature request as it directly contradicts with the fundamental design of the component - more specifically, the AutoComplete supports binding to string values only:
https://www.telerik.com/kendo-angular-ui-develop/components/dropdowns/autocomplete/value-binding#value-binding
The value/valueChange Input/Output combination serves the purpose of allowing the natural Angular two-way binding syntax - [(value)]="myValue", and thus the event data that is automatically assigned to the component value needs to be a string too.
To obtain the complex data object in the valueChange event handler, the developer can perform a simple array opperation (e.g. filter or find) and provide a predicate that matches the event data with the field configured as valueField of the data item, e.g.:
https://www.telerik.com/kendo-angular-ui-develop/components/dropdowns/autocomplete/data-binding#arrays-of-complex-data
https://stackblitz.com/run/?file=src%2Fapp%2Fapp.component.ts
Regards,
Dimiter Topalov
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Hi Andrew,
Did you get any solution for it?
Regards,
Rutvik Nagarkar
a kendoAutoCompleteValueTemplate would also be handy.
I thought I had a workaround for this using the template however, stop prop is called on enter if the popup is open (I get the reasoning).
<span (keydown)="getSelectedItem(dataItem)" (click)="getSelectedItem(dataItem)">{{ dataItem.formatted_address }}</span>
if you only care about click and never expect the user to hit enter then this could work for you.
I agree this would be great to have access to the selected object. I thought this would be supported as the template exposes the data items but it just complains that the value is not a string. Even if the value change sent the full object, index, and new value that would work as well. But having the selection change would be boss so if you wanted to hijack the selection you could do that before the value change.