Search code examples
javascriptjquerykendo-uikendo-dropdown

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.


Solution

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