获取kendo下拉值的所选ID [英] get selected id of kendo drop down value

查看:352
本文介绍了获取kendo下拉值的所选ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从下拉列表中获取所选名称的ID。

当选择苹果然后获取ID 1 并选择 Oranges 然后 2

这是简单的kendo下拉列表示例。 br>

how to get id of selected name from dropdown.
whene select Apples then got id 1and select Oranges then 2.
this is simple kendo dropdown example.

<body>
            <input id="dropdownlist" />

            <script>
                $("#dropdownlist").kendoDropDownList({
                  dataSource: [
                    { id: 1, name: "Apples" },
                    { id: 2, name: "Oranges" }
                  ],
                  dataTextField: "name",
                  dataValueField: "id",
                  index: 1,
                  select: onSelect
                });

                function onSelect(e) {
                console.log(e);
                  };
            </script>
</body>

谢谢。

推荐答案

选择事件有点困难,因为事件在选择项目之前触发。

The Select event is a bit more difficult one to use, as that event fires before the item is selected.

如果您使用Change事件,你应该能够获取dataItem与

If you use the Change event, you should be able to get the dataItem with

this.dataSource.get(this.value())

请参阅示例 http://jsbin.com/OcOzIxI/2/edit

这篇关于获取kendo下拉值的所选ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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