This is a migrated thread and some comments may be shown as answers.

ValueTemplate for Combobox ??

1 Answer 752 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sebastien
Top achievements
Rank 1
Sebastien asked on 28 Jun 2018, 04:08 PM

Hi, 

 

Why is there no valueTemplate for the combobox component ? This is a must have. It is available in the DropDownList but not in ComboBox...
So withing the combobox, I can customize the itemTemplate but I want the value text to be the same as the item text. 

Actually, for each item, I concatenate several string representing different attributes of the object.

I want to be able to display the same information when the item is selected (ValueTemplate). 

For example, consider an object : 

country = {

  code: US

  longCode: United-Stated

}

I want to be able to display "United-States - US", both in the list and in the value when the item is selected.

Thanks in advance. 

1 Answer, 1 is accepted

Sort by
0
Accepted
Alexander Popov
Telerik team
answered on 02 Jul 2018, 05:07 AM
Hello Sebastien,

The lack of valueTemplate in the ComboBox is not a missing feature, but is by design. Basically the <input> element inside the ComboBox displays one of two things - either the valueField of an object value OR the string representation of a primitive value. In both cases it displays a simple text inside an <input> element, which has rather limited use of a template and is also editable by the user. The DropDownList on the other hand displays the value inside a non-editable HTML element, which allows for safe and customizeable use of templates. Perhaps a filterable DropDownList using a template is the closest to what you are looking for. Alternatively you could use a map operator to manually modify the data before feeding it to the ComboBox.

Regards,
Alexander Popov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
General Discussions
Asked by
Sebastien
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or