Declined
Last Updated: 23 Feb 2022 14:04 by ADMIN
Frank
Created on: 21 Feb 2022 09:35
Category: AutoComplete
Type: Feature Request
1
allow retreiving the selected item when binding a complex model to the autocomplete control
Hello, 
I'm using the autocomplete control to bind a comlex model to it.
Binding a complex model is currently supported by the autocomplete control:
https://docs.telerik.com/blazor-ui/components/autocomplete/data-bind#bind-to-a-model
When selecting an item from this list, it is necessary to retreive the selected item.
It seems to me that at the moment the .ToString Method is called on the selected item. 
That results in displaying type information at the UI and providing the type information when the "MyOnChangeHandler" function ist called ( 02.jpg, 03.jpg).
And because the OnChange event handler needs to implement a function with an object as a parameter ( 03.jpg ) I'm wondering how the selected item can retreived.
Instead ob providing a .ToString() - information when binding to a complex type you need to provide the selected item.

And by the way, when selecting an item the ItemTemplate ( 04.jpg ) seems to be ignored when displaying this selected item.
3 comments
ADMIN
Dimo
Posted on: 23 Feb 2022 14:04

Hi Frank,

We use .ToString() to display non-string properties defined in the ValueField parameter of the AutoComplete. We can't render anything on the page, if it is not a string or not stringified first.

If you see a fully qualified name inside the AutoComplete, this means that ValueField is pointing to a complex object, instead of a primitive (string) property.

Regards,
Dimo
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Frank
Posted on: 23 Feb 2022 13:47
Hello,
well declining a feature request ist easy for you.
I am still not able to get the idea behind displaying a ".ToString() - type information" everytime a user selects an item.



Nevertheless I would like to know:

What should a user thinks when he or she sees that kind of information ?
What benefit has a user, when he or she sees the type information of the selected object ?
Is it imaginable for you that a user might think that tis is a bug in the autocomplete control he or she uses ?

ADMIN
Dimo
Posted on: 22 Feb 2022 10:31

Hi Frank,

This feature request was created before we discussed a similar topic in a private ticket. I am pasting the highlights here for visibility to other members of our community:

  • The whole data item cannot be retrieved in OnChange or OnValueChanged. The event argument is always the value of the data item property set in the ValueField. It is very unlikely for us to expose the whole data item in these event arguments in the future. This is a huge breaking change that is not justified.
  • Usually, one can get the data item from the selected string value via standard collection methods. If there are several data items with different IDs and the same string value, then the ComboBox is the more appropriate component to use. It has separate ValueField and TextField, and the value will be unique.

This topic is a new one here:

  • The AutoComplete ItemTemplate cannot affect the textbox content (the same applies to ComboBoxes). The textbox value can only match a single property value from a data item. Alternatively, it can hold custom value that is not part of the data. If you need custom value  display, use a DropDownList with a ValueTemplate.

Regards,
Dimo
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.