Kendo UI Dropdownlist: how add new elements dynamically

Tom picture Tom · Apr 4, 2015 · Viewed 7.5k times · Source

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.

Answer

Nicholas picture Nicholas · Apr 4, 2015

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