简体   繁体   中英

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?

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.

You can use the add() method of the Kendo datasource to add new items:

var ddl = $("#dropDownListID").data("kendoDropDownList");
var dataSource = ddl.dataSource.add({
    "text": "new Item", 
    "value": 1000});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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