setDataSource

Sets the data source of the widget.

Parameters

dataSource kendo.data.HierarchicalDataSource

The data source to which the widget should be bound.

Example - set the data source

<div id="treeMap"></div>
<script>
$("#treeMap").kendoTreeMap({
    dataSource: {
        data: [{
            name: "foo",
            value: 1,
            color: "red"
        }]
    },
    valueField: "value",
    textField: "name",
    colorField: "color"
});

var dataSource = new kendo.data.HierarchicalDataSource({
    data: [{
        name: "foo",
        value: 1,
        items: [{
            name: "bar",
            value: 1
        },{
            name: "baz",
            value: 1
        }]
    }],
    schema: {
        model: {
            children: "items"
        }
    }
});

var treeMap = $("#treeMap").getKendoTreeMap();
treeMap.setDataSource(dataSource);
</script>
In this article