[英]Kendo UI Dropdownlist: how add new elements dynamically
How can I add a new item in a Kendo DropDownlist, if it doesn't exist in the datasource? 如果数据源中不存在新项目,如何在Kendo DropDownlist中添加新项目?
Example: the Kendo DropDownlist shows some predefined values, but the user should also be able to add a new item by writing in an input text. 示例:Kendo DropDownlist显示一些预定义的值,但是用户也应该能够通过输入输入文本来添加新项。
You can use the add()
method of the Kendo datasource
to add new items: 您可以使用Kendo
datasource
的add()
方法添加新项目:
var ddl = $("#dropDownListID").data("kendoDropDownList");
var dataSource = ddl.dataSource.add({
"text": "new Item",
"value": 1000});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.