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

TreeView with Self Referencing Hierarchy

1 Answer 271 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Joey
Top achievements
Rank 1
Joey asked on 07 Sep 2016, 09:29 PM

I'm trying to set up a TreeView. My json data from the server has IDs and Parent IDs that contain what the hierarchy is. Root levels have parentId of "NULL". Can I not specify my hierarchy self-referentially like this? Do I HAVE to make an "items: []" sub-structure in my JSON for each parent node?

 

var ds = new kendo.data.HierarchicalDataSource({
            transport: {
                read: function(e) {
                    //JSON is returned here. Example [{id: 50, parentId: "NULL", name: "abc"}, {id: 51, parentId: 50, name: "xyz"}]
                }
            },
            schema: {
                model: {
                    id: "id",
                    parentId: "parentId",
                    fields: {
                        id: { type: "number" },
                        parentId: { type: "number", defaultValue: 0 }
                    }
                }
            }
        });

 

1 Answer, 1 is accepted

Sort by
0
Dimiter Topalov
Telerik team
answered on 10 Sep 2016, 07:56 AM
Hi Joey,

Please find the answer to this, and your other related question, in the following forum topic:

http://www.telerik.com/forums/treeview-not-displaying-intended-hierarchy-from-self-referencing-data-source#BYFsSGu5qUSjpT6SqYO0pw

Regards,
Dimiter Topalov
Telerik by Progress
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
Tags
TreeView
Asked by
Joey
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Share this question
or