setDataSource
Sets the data source of the widget.
Parameters
dataSource kendo.data.TreeListDataSource
The data source to which the widget will be bound.
Example - setting 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>