This is a migrated thread and some comments may be shown as answers.
Datasource not updating after append
1 Answer 19 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Niranjan asked on 19 Jan 2018, 05:32 AM

I have a tree with 5 levels => L1, L2, L3, L4 & L5, the tree implements lazy loading. Hence only L1 level nodes are currently in the datasource.

I accept an input from the user that has 5 Id's. Each of which corresponds to one level of the tree. EX : Id1 => L1, Id2 => L2 and so on...

        var treeview = $("#treeView").data("kendoTreeView");
        var dataSource = treeview.dataSource;
        var data = dataSource.get(Id1);
        var levelonenode = treeview.findByUid(data.uid);
        // Logic to append the child nodes of levelonenode (with one of the child nodes having id =Id2)

//now when i check the debugger, the append operation is complete but the dataSource shows that levelonenode doesn't have any children yet.

       var leveltwodata = dataSource.get(Id2);
//does not exist

I suspect that the children have been appended but havent yet been rendered on the UI so the dataSource hasnt been refreshed.

Is there a workaround for this?

Any help would be appreciated!


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 22 Jan 2018, 05:22 PM
Hello Niranjan,

The Kendo UI TreeView uses hierarchical data. When configured with loadOnDemand set to true, children nodes are being loaded lazily (remote request is triggered upon expanding a node that retrieves the data). The DataSource of the widget contains information about the currently loaded dataItems. Each dataItem has a children property, which will be populated with data only if it is already loaded from the remote service (node is expanded).

You can verify that this is the case by subscribing to the TreeView's dataBound event, where you can get currently loaded dataItems with the method and process them further according to your requirements. 

Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question