All of the examples I have seen for the HierarchalDataSource show binding, either to local data, somewhat artificially hard coded, or to remote data that is assumed to be already in json hierarchal format.
I, however, have a flat datasource from which I need to build a hierarchy. So I started out with the following code (html not shown). The question is how to create the children (and further children of children). Obviously this needs to get more complex because I will need to access my own flat data records and also I will need templates for all nodes. But pointers for this would be a great help. Thanks in advance.
(function () {
'use strict';
angular.module('FieldTreeApp', ['kendo.directives'])
.controller('FieldTreeViewCtlr', function ($scope) {
$scope.treeOptions = {
dataSource: makeData()
};
function makeData() {
var ds = new kendo.data.HierarchicalDataSource();
ds.add({
text: "My first node"
});
ds.add({
text: "My second node"
});
var x = ds.data(); // Does get my data.
return ds; // This does create the 2 top level nodes.
}
I, however, have a flat datasource from which I need to build a hierarchy. So I started out with the following code (html not shown). The question is how to create the children (and further children of children). Obviously this needs to get more complex because I will need to access my own flat data records and also I will need templates for all nodes. But pointers for this would be a great help. Thanks in advance.
(function () {
'use strict';
angular.module('FieldTreeApp', ['kendo.directives'])
.controller('FieldTreeViewCtlr', function ($scope) {
$scope.treeOptions = {
dataSource: makeData()
};
function makeData() {
var ds = new kendo.data.HierarchicalDataSource();
ds.add({
text: "My first node"
});
ds.add({
text: "My second node"
});
var x = ds.data(); // Does get my data.
return ds; // This does create the 2 top level nodes.
}