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

Why ComboBox .text() is automaticly copied to .value

3 Answers 443 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
VasVas
Top achievements
Rank 1
VasVas asked on 10 May 2015, 06:11 AM

Dear Telerik,

I have the fallowing problem reported by my QA team on a page with moltipale comboboxs the value of the combo shows up as the combo syncs with server data the it disappears and is synced.

As I was checking this I see that the fields .value() and text(). of the kendo ui ComboBox have this strange behavior. They sync with each other. When I change the text in the combo box value is set to the text current value. This can be seen an the kendo ui demo basic usage , by writing "Item 4" in the combo and the value() and the text() of the combo will both be "Item 4". This could cause problem if the data arrived at the server when a code is expected. In my view .text should not be synced to the .value. If there  selection of the value.

 here is a disction of this :

 

http://stackoverflow.com/questions/18870746/avoid-combobox-sending-values-that-arent-on-the-list

 

Yours,

 

Ariel

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 12 May 2015, 04:07 PM
Hello Ariel,

Generally speaking, the main purpose of the Kendo UI ComboBox is to allow custom values along with selection from a predefined list. When typed text is not part of the datasource, then it is considered as custom and both text and value are synced. This is the main difference (to be honest, it is the only one) between combobox and dropdownlist.

If you would like to prevent custom values, then the best solution is to use DropDownList. If using a dropdownlist is not possible, then please refer to this how-to demo that demonstrates how to clear the entered custom value.

To sum up, the described behavior is expected and intended. If this is not desired, then the best solution will be to use DropDownList.

Regards,
Georgi Krustev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
VasVas
Top achievements
Rank 1
answered on 17 May 2015, 07:03 AM

Dear Georgi,

I wanted to know if using the code from the cascade event is not better then working with the change event.

This will prevent the by pruduct ("of the By design behavior") that in screens with multiple combo boxes , the code (value) is shown in the combo box . if  1= male 2=female. the combo will show 1 for a second and then sync. If I use the code you gave me and implement in the cascade event instead of the change event this will cancel this behavior. or must I implement in both events (that will cause a infinite recursive loop?)

 

Ariel

 

 

0
Georgi Krustev
Telerik team
answered on 20 May 2015, 06:53 AM
Hello Ariel,

Using "cascade" event should be sufficient to accomplish your goal (clearing the custom value). That being said, you can go only for the "cascade" event.

Regards,
Georgi Krustev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ComboBox
Asked by
VasVas
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
VasVas
Top achievements
Rank 1
Share this question
or