如何修改 KendoUI DropDownList 项 [英] How to modify KendoUI DropDownList items

查看:10
本文介绍了如何修改 KendoUI DropDownList 项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们第一次使用 Kendo UI DropDownList,没有绑定淘汰赛.通过 jquery,通常的 html 输入被转换为 KendoUI DropDownList.但是我如何删除/编辑/添加项目到选项中?

We used the Kendo UI DropDownList the first time without binding with knockout. Via jquery a usual html input is transformed into a KendoUI DropDownList. But how can i remove/edit/add items to the options?

如果我通过 jquery 修改 html 输入选项,它对 kendoui 下拉列表没有影响 - 即使之后有刷新调用.

If i modify the html inputs options via jquery it has no influence on the kendoui dropdown - even with a refresh call afterwards.

任何想法如何做到这一点?谢谢

Any ideas how to do this? Thanks

推荐答案

你好

您应该使用组合框的dataSource.例如

You should use the dataSource of the combobox. e.g.

var ds = $('#YourCombo').data().kendoComboBox.dataSource;

然后你可以像这样修改项目

then you can modify the items like this

//someIndex is the index of the item in the dataSource
ds.data()[someIndex].set("text","Cool! its changed");

使用dataSource的addremove方法来添加或删除项目

to add item or remove use the add and remove methods of the dataSource

ds.add({text:"Test again!",value:"5"});

这篇关于如何修改 KendoUI DropDownList 项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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