0
votes

I have a Kendo HierarchicalDataSource object bound to a Kendo treeview widget.

The HierarchicalDataSource simply returns a one-level-deep json formatted object, but for some reason it won't render in the treeview. It just shows the top node "Dimensions", but renders no data when expanded.

Here is my plunk treeview sample , which contains index.html and script.js .

FYI for script.js : $scope.dimenDataSource is the Kendo HierarchicalDataSource object which uses the transport property to call my method getDimensionsFromServer2 and also specify the schema.

Another FYI: In getDimensionsFromServer2() I have two ways of returning my test data. The dataFlat var returns a flat array, which renders fine. The data object has nested data, but does NOT render in treeview.

I'm not sure what's going wrong.

Thank you, Bob

**** UPDATE ****

The problem was the incorrect placement of the schema setting (see my answer):

settings.dimenDataSource = new kendo.data.HierarchicalDataSource({
  transport: {                
    read: function(options){
      datacontext.getDimensionsFromServer().then(function (data) {
        var rootnode = [{ name: "Dimensions", items: data.data }];
        options.success(rootnode);
      });
    },
    schema: {
       model: { children: "items" }
    },
    loadOnDemand: false                
  }
});
1

1 Answers

0
votes

My mistake was in the schema placement, which I had inadvertently placed in the transport option. It should placed at the same level, not within it.

Here's is the corrected version:

settings.dimenDataSource = new kendo.data.HierarchicalDataSource({
  transport: {                
    read: function(options){
      datacontext.getDimensionsFromServer().then(function (data) {
        var rootnode = [{ name: "Dimensions", items: data.data }];
        options.success(rootnode);
      });
    },
    loadOnDemand: false                
  },
  schema: {
    model: { children: "items" }
  }
});