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

查看:269
本文介绍了如何修改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

推荐答案

Yo mate

你应该使用组合框的 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的方法

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天全站免登陆