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

How can I check whether a input value already exist in combobox's option

1 Answer 1152 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Chobits
Top achievements
Rank 1
Chobits asked on 10 Nov 2012, 02:56 PM
I use combobox,I want to know whether user input value already exist in combobox's option
i use $('#select option[value='input vale']') , but can't

1 Answer, 1 is accepted

Sort by
0
Richo
Top achievements
Rank 1
answered on 26 Nov 2012, 05:17 AM
If i understand correctly, u wand to know wheter the input value exist in binded values. For this case i use the follow js:

cmbChangeWorkType: function () {
    var combobox = $('#WorkTypeId').data('kendoComboBox');
    var ds = combobox.dataSource;
    var value = combobox.value();
    var data = ds['_data'];
    var item = pdInfo.getByGuid(data, value);
    if (item == null) { // check wheter the input value exist in binded values
        combobox.value(null); // set the null if value not in list
    }
},

getByGuid: function (data, guid) {
    for (var i = 0; i < data.length; i++) {
        if (data[i]['Guid'] == guid) {
            return data[i];
        }
    }
    return null;
},
Tags
ComboBox
Asked by
Chobits
Top achievements
Rank 1
Answers by
Richo
Top achievements
Rank 1
Share this question
or