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

Adding a subtree under a already rendered tree node

5 Answers 74 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Craig
Top achievements
Rank 1
Craig asked on 15 Feb 2017, 09:04 PM

So I have done my initial loading of the TreeList with datasource read. During that time I cache off the DataSourceTransportOptions passed into the read method

This tree shows fine initially but I am trying to then load a subtree with many nodes under a user selected node.  I download the partial subtree  of data and have the id's and parentId's set properly and use the cached DataSourceTransportOptions to call options.success(myCompleteList).  My expectation is that my data would be inserted into the correct location but it appears to screw up the id's and parentId's of the rendered data.

I have confirmed that the id's and parent id's of my data is correct just that the view is not.

Obviously, I am doing something wrong or perhaps it is a limitation that I cannot build up a tree a subtree at a time.

-Craig

 

5 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 17 Feb 2017, 02:27 PM
Hello Craig,

I was not able to reproduce the described issue on my end.

Still, in this scenario, I can suggest using the data method of the dataSource to retrieve the current tree data, then add the new tree to it and set the new data using again the data method:

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-data

I made a Dojo example demonstrating this implementation:

http://dojo.telerik.com/IsEzI

I hope this is helpful.

Regards,
Stefan
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data (charts) and form elements.
0
Craig
Top achievements
Rank 1
answered on 21 Feb 2017, 08:45 PM

Hi Stefan,

The suggestion to add it directly to the datasource.data() seemed to do the trick.  We have used the technique of reusing the options.success() after the initial load with other controls but the this control seemed to not like this.

Thanks

Craig

0
Omar
Top achievements
Rank 1
answered on 12 Sep 2017, 09:54 PM

Hello Stefan,

    In your dojo example:

http://dojo.telerik.com/IsEzI

    If the data objects rename the attributes "id" for "att_id" and "parentId" for "att_parentId" and consider such changes for the model in the TreeDataSource :

model: {
   id: "att_id",
   fields : {
      parentId : { field: "att_parentId", nullable: true }
   }
}

The subtree is not loaded, is such behavior a bug?
0
Stefan
Telerik team
answered on 14 Sep 2017, 11:08 AM
Hello Omar,

When the names are different this is expected because the data method will not use the schema.model configuration to parse the set data items.

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-data

"The schema.model configuration will not be used to parse the set data items. The data should be parsed in advance and the values should be provided in the correct type - date values should be JavaScript Date objects, numeric values should be JavaScript numbers, and others."

In this case, the new objects have to have a parentId instead of some_name_parentId.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Omar
Top achievements
Rank 1
answered on 18 Sep 2017, 04:12 PM

Hello Stefan,

Excellent! ... Thanks a lot for the clarification.

Regards.

Tags
TreeList
Asked by
Craig
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Craig
Top achievements
Rank 1
Omar
Top achievements
Rank 1
Share this question
or