简体   繁体   English

如何修改KendoUI DropDownList项目

[英]How to modify KendoUI DropDownList items

We used the Kendo UI DropDownList the first time without binding with knockout. 我们第一次使用Kendo UI DropDownList而没有敲除绑定。 Via jquery a usual html input is transformed into a KendoUI DropDownList. 通过jquery,通常的html输入被转换为KendoUI DropDownList。 But how can i remove/edit/add items to the options? 但是如何删除/编辑/添加选项?

If i modify the html inputs options via jquery it has no influence on the kendoui dropdown - even with a refresh call afterwards. 如果我通过jquery修改html输入选项,它对kendoui下拉列表没有影响 - 即使之后有刷新调用。

Any ideas how to do this? 任何想法如何做到这一点? Thanks 谢谢

Yo mate 哟伙伴

You should use the dataSource of the combobox. 您应该使用组合框的dataSource eg 例如

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

to add item or remove use the add and remove methods of the dataSource 添加项目或删除使用dataSource的添加删除方法

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM