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

[Solved] Which value is the text, and which value is the value?

1 Answer 98 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jay
Top achievements
Rank 1
Jay asked on 03 Feb 2012, 07:58 PM
Ok, so I'm struggling here on finding out which value is the right value.   Take your example here:

http://demos.telerik.com/aspnet-mvc/combobox/clientsideevents

If you select 'Chai' as the dropdown value.   The OnChange event has '2' as the value.

But if you type '2' in the box.  The OnChange event has '2' as the value.

How do I know which is which?  I don't see anything in the event that tells me that it's an unbound value.

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 06 Feb 2012, 11:49 AM
Hello Jeff,

 
If the selectedIndex is -1, then no item is selected and the value is a custom text:

function onChange(e) {
    var combobox = $(this).data("tComboBox").se
    if (combobox.value() && combobox.selectedIndex == -1) {
       alert("custom value");
    }
}

Regards,
Georgi Krustev
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
ComboBox
Asked by
Jay
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or