This is a migrated thread and some comments may be shown as answers.

Treeview loaded from remote data source will not expand

1 Answer 223 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Aaron
Top achievements
Rank 1
Aaron asked on 02 Mar 2013, 05:03 AM
Help! I have NO idea what I'm doing wrong!  The initial node loads and shows an expand icon but nothing happens when it's clicked.  No request is even attempted. I have the following code:
var homogeneous = new kendo.data.HierarchicalDataSource({
    transport: {
        read: {
            url: 'http://localhost:500/api/users/',
            dataType: "json"
        }
    },
    schema: {
        model: {
            id: "id",
            hasChildren: "load_on_demand"
        }
    }
});
 
$("#tree").kendoTreeView({
    dataSource: homogeneous,
    dataTextField: "label"
});

The  'http://localhost:500/api/users/' is an ASP.NET Web API controller method that returns the following JSON:

[{"id":12345,
  "label":"NODE 1",
  "load_on_demand":true
}]

What am I doing wrong? Any ideas would help!

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 06 Mar 2013, 06:05 AM
Hello Aaron,

The code you provided looks correct. A problem with expanding the node might occur if the element used for the treeview is <ul> because this way the nodes will be determined from the markup or from the initial data. You should define the treeview container(<div> ) instead in this case. I also created a small jsFiddle example showing similar scenario.

Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
TreeView
Asked by
Aaron
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or