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

Manually Add Nodes to TreeView with OnDemand Loading

1 Answer 161 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 18 Jan 2013, 06:00 PM

Kendo UI V. 2012.2.924

So I'm trying to do something pretty messed up with my kendo tree view. The situation is this: I have a kendo tree view with on demand loading. I also implemented special placeholder nodes that can be clicked to append additional nodes to each level (as a way of batching).

The feature I need to implement is a search. The user can enter a node name and the tree will expand to that node and select it. I have all the logic on the server figured out. The only problem is that with ondemand loading, every time I append a node to a parent, there is a server call to get the contents of that parent. I want to disable this automatic call until my manual appends have been completed. Anyone know if this can be done? I have tried from the server, but if I just return null it has an error. If I return an empty list, it wipes out the existing appended nodes.

Any help would be appreciated.

1 Answer, 1 is accepted

Sort by
0
Accepted
Vladimir Iliev
Telerik team
answered on 22 Jan 2013, 12:11 PM
Hi Paul,

The case that you explained is not supported out-of-the-box at this time. A possible solution could be to , create a custom hierarchical schema for all levels of the data down to the found node with local DataSources for the cached data and a remote DataSource for the found element when you receive the response from the server:

dataSource: {
    // data for level 1
    data: [
        { text: "foo", hasChildren: true }
    ],
    schema: {
        model: {
            hasChildren: "hasChildren",
            children: {
                // data for level 2
                data: [
                    { text: "bar", hasChildren: true }
                ],
                schema: {
                    model: {
                        hasChildren: "hasChildren",
                        children: {
                            // level 3 is fetched remotely
                            transport: {
                                read: {
                                    url: "/home/jsondata/"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

Also the current version that you are using is InternalBuild and I would recommend you to upgrade to stable release - KendoUI 2012 Q3 SP1 - v.2012.3.1315.
Kind Regards,
Vladimir Iliev
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
Paul
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or