Edit this page

setDataSource

Sets the data source of the widget.

Parameters

dataSource kendo.data.TreeListDataSource

The data source to which the widget should be bound.

Example - set the data source

<button id="btn">Change DataSource</button>
<div id="treeList"></div>
<script>
  $("#treeList").kendoTreeList({
    columns: [
      { field: "id" },
      { field: "name" },
      { field: "age" }
    ],
    dataSource: [
      { id: 1, parentId: null, name: "Jane Doe", age: 22, expanded: true },
      { id: 2, parentId: 1, name: "John Doe", age: 24 },
      { id: 3, parentId: 1, name: "Jenny Doe", age: 3 }
    ]
  });
  $("#btn").click(function(){
    var treeList = $("#treeList").data("kendoTreeList");
    var dsNew = new kendo.data.TreeListDataSource({
      data: [
        { id: 1, parentId: null, name: "Mark Jameson", age: 26, expanded: true },
        { id: 2, parentId: 1, name: "Joe Reeves", age: 22 },
      ]
    });
    treeList.setDataSource(dsNew);
  });
</script>
Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy