Tom
Tom

Reputation: 4107

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.

Upvotes: 1

Views: 9540

Answers (1)

Nic
Nic

Reputation: 12895

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

Upvotes: 3

Related Questions