Kendo UI Web - DropDownList: select event doesn't return selected value properly

Glenn Mohammad picture Glenn Mohammad · Feb 6, 2014 · Viewed 13.3k times · Source

I am binding a DropDownList widget to select event like so:

var items = [
    { text: 'Item 3', value: '3' },
    { text: 'Item 4', value: '4' }
];

var dropDownListEl = $('#dropdownlist');
dropDownListEl.kendoDropDownList({
    dataTextField: 'text',
    dataValueField: 'value',
    index: 0
});

var kDropDownList = dropDownListEl.data('kendoDropDownList'),
    ds = kDropDownList.dataSource;

items.forEach(function (item) {
    ds.add(item);
});

kDropDownList.bind('select', function (e) {
    console.log('this.value(): ' + this.value());
});

But, it doesn't return the correct value when I do the selection.

I have been trying almost every possibility there is, none is working. http://jsfiddle.net/glenn/gxJ3S/

It's driving me insane!

Answer

Goddard picture Goddard · Feb 6, 2014

Binding Select Event of Kendo DropDownList as follow to get correct selected item

   kDropDownList.bind('select', function (e) {
       var dataItem = this.dataItem(e.item.index());
        console.log('this.value(): ' + dataItem.value);

   });

Here is the working JSFiddle