John Hornsby
John Hornsby

Reputation: 321

Can't get Kendo UI TreeView to read children in JSON data correctly

http://jsfiddle.net/N8Svz/5/

I'm sure I must be doing something kind of dumb; this seems like a textbook usage of HeirarchicalDataSource as far as I can tell.

var domtree = [{
    "id": "linear1",
    "element-class": "LinearLayout",
    "children": [{
        "id": "static1",
        "element-class": "Static"
    }, {
        "id": "static2",
        "element-class": "Static",
        "children": [{
            "id": "static3",
            "element-class": "Static"
        }]
    }, {
        "id": "4",
        "element-class": "Error"
    }]
}];

var inline = new kendo.data.HierarchicalDataSource({
    data: domtree,
    schema: {
        model: {
            id: "id",
            children: "children"
        }
    }
});

$("#navtree").kendoTreeView({
    dataSource: inline,
    dataTextField: "id"
});

A big thank you to anyone who can point out what I'm doing wrong!

Upvotes: 1

Views: 1175

Answers (2)

Wray Smallwood
Wray Smallwood

Reputation: 87

If you add the schema property like this it may work. You are telling the hierarchical datasource what the key for children is. Something like this:

schema: { model: { children: "children" } }

Upvotes: 0

Noampz
Noampz

Reputation: 1205

I just change the field children to items.

here's a jsfiddle: http://jsfiddle.net/nn007/N8Svz/6/

Upvotes: 1

Related Questions