add
Adds an item to the widget.
Example
<select id="listBox"></select>
<script>
$("#listBox").kendoListBox({
dataSource: {
data: [
{ name: "Jane Doe" },
{ name: "Sam Doe" }
]
},
template: "<div>#:name#</div>"
});
var listBox = $("#listBox").data("kendoListBox");
var person = {name: "Bob Doe"};
listBox.add(person);
</script>
Example
<select id="listBox"></select>
<script>
var Product = kendo.data.Model.define({
id: "ProductID",
fields: {
ProductName: {
type:"string"
}
}
});
var dataSource = new kendo.data.DataSource({
data:[
{ProductID:1, ProductName:"Apples"},
{ProductID:2, ProductName:"Oranges"},
],
schema: {
model: Product
}
});
$("#listBox").kendoListBox({
dataSource: dataSource,
dataTextField:"ProductName",
dataValueField:"ProductID"
});
var listBox = $("#listBox").data("kendoListBox");
var item = new Product({ProductName:"Bananas"});
listBox.add(item);
</script>