Kendo UI Web-DropDownList:select事件未正确返回所选值 [英] Kendo UI Web - DropDownList: select event doesn't return selected value properly

查看:178
本文介绍了Kendo UI Web-DropDownList:select事件未正确返回所选值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将DropDownList小部件绑定到select事件,如下所示:

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.

我一直在尝试几乎所有可能的方法,但没有一种在起作用. http://jsfiddle.net/glenn/gxJ3S/

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

这让我发疯了!

推荐答案

如下绑定 Kendo DropDownList Select Event ,以获取正确的所选项目

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);

   });

这是正在工作的JSFiddle

这篇关于Kendo UI Web-DropDownList:select事件未正确返回所选值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆