setDataSource

Sets and binds a dataSource to the widget.

Note: Calling this method with an array will not change the loadOnDemand flag, unlike initialization with an array option.

Parameters

dataSource kendo.data.HierarchicalDataSource

The new dataSource that the widget will bind to

Example

<div id="treeview"></div>
<script>
$("#treeview").kendoTreeView({
  dataSource: [
    { text: "foo", items: [
      { text: "bar" }
    ] }
  ]
});

var treeview = $("#treeview").data("kendoTreeView");

treeview.setDataSource(new kendo.data.HierarchicalDataSource({
  data: [
    { text: "bar", items: [
      { text: "baz" }
    ] }
  ]
}));
</script>
In this article