setDataSource

Sets the dataSource of an existing ListBox and rebinds it.

Parameters

dataSource kendo.data.DataSource

Example

<select id="listBox"></select>
<script>
$("#listBox").kendoListBox({
    dataValueField: "id",
    dataTextField: "name",
    dataSource: {
        data: [
            { id: 1, name: "United States" },
            { id: 2, name: "France" }
        ]
    }
});
var dataSource = new kendo.data.DataSource({
    data: [
        { id: 3, name: "Germany" },
        { id: 4, name: "Sweden" }
    ]
});
var listbox = $("#listBox").data("kendoListBox");
listbox.setDataSource(dataSource);
</script>

Example

<select id="listBox"></select>
<script>
$("#listBox").kendoListBox({
  dataSource: [ "Apples", "Oranges" ]
});
var dataSource = new kendo.data.DataSource({
  data: [ "Bananas", "Cherries" ]
});
var listbox = $("#listBox").data("kendoListBox");
listbox.setDataSource(dataSource);
</script>
In this article