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

Change TreeView Datasource from remote to local

4 Answers 388 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Grant
Top achievements
Rank 3
Iron
Iron
Veteran
Grant asked on 19 Jan 2017, 08:59 AM

Hi, 

I have a treeview which loads its nodes dynamically on expand, which works fine. I also have a button to 'Expand All' to open all nodes as far as the tree goes.

Unfortunately I have no way of knowing how big the tree is or how deep it goes until the data is loaded. So instead of recursively calling '.expand()' until there are no more closed nodes (which would make 10's of server requests for data), I would rather Retrieve the entire tree, and reset the dataSource to a local one that contains all the entire tree.

I'm having some trouble though, when I reset the DS to local and expand a node, the tree is still making a request call which retrieved the entire tree again as node contents. Note that I am also trying to set loadOnDemand to false, but its having no affect.

Any advice on this scenario would be great.

Thanks,
Grant

4 Answers, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 23 Jan 2017, 07:44 AM
Hello Grant,

Here you will find a Dojo sample, implementing the described scenario. The TreeView is initially configured to work with remote DataSource. On click of the button the DataSource is changed to a local one, using the setDataSource() method. Then all the nodes are expanded.

May I ask you to modify the above, so it reproduces the issue faced at your end and send back to us?

Regards,
Veselin Tsvetanov
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 visualization (charts) and form elements.
0
Grant
Top achievements
Rank 3
Iron
Iron
Veteran
answered on 23 Jan 2017, 08:44 AM

Hi Veselin,

Thanks for the helpful response. Unfortunately I must apologize. After re-reading my question, I realized that my code did not represent the question I was asking. So I apologize for wasting your time. When I reset the DS I was setting it to another remote location that returned a full Hierarchical tree. It obviously isn't static and so wouldn't be treated as such by kendo.

I has however lead me to a related question. I've updated your example with an additional level under 'Occasional Furniture', and I noticed that when you call .expand('.k-item'), it only expands the first level of nodes. Is there a way to recuse the expanding until the end of the tree, without knowing what nodes the tree contains (cannot use expandPath() or expandTo() as I wont know what the tree will contain)?

Thanks and kind regards,
Grant

0
Grant
Top achievements
Rank 3
Iron
Iron
Veteran
answered on 24 Jan 2017, 08:05 AM

I've managed to resolve this issue by surrounding the .expand() with a while..do.

FYI: http://dojo.telerik.com/ALOsa/6

Thanks anyway,
Grant

0
Veselin Tsvetanov
Telerik team
answered on 24 Jan 2017, 03:40 PM
Hello Grant,

Thank you for getting back to us and letting us know how you have approached the discussed scenario.

Regards,
Veselin Tsvetanov
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 visualization (charts) and form elements.
Tags
TreeView
Asked by
Grant
Top achievements
Rank 3
Iron
Iron
Veteran
Answers by
Veselin Tsvetanov
Telerik team
Grant
Top achievements
Rank 3
Iron
Iron
Veteran
Share this question
or