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

MVVM with remote data

3 Answers 27 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 20 Nov 2018, 02:28 PM

How can I use the tree view with MVVM while at the same time only fetching the nodes that I need.  The sample shows setting up the observableHierarchy and that is it.  Is it even possible?

 

I know i can set hasChildren to be true on the parent, but how do i then grab the children?

3 Answers, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 22 Nov 2018, 08:35 AM
Hi Mike,

In order to load TreeView nodes from remote endpoint on demand, you could use a kendo.data.HierarchicalDataSource object instead of the observableHierarchy available in the demo sample. Here you could find a simple Dojo implementing such scenario.

Regards,
Veselin Tsvetanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Mike
Top achievements
Rank 1
answered on 23 Nov 2018, 04:08 AM

What do I lose by switching? Will i be able to add items to the datasource and the control automatically updates still? I have a need for both cases, the remote is more for the initial load only.

 

I've been experimenting and with the virtualization, we may just send our dataset down in hierarchial form and call it a day.  I don't see any major performance issues as of yet even with a large amount of root nodes.

0
Veselin Tsvetanov
Telerik team
answered on 26 Nov 2018, 09:50 AM
Hello Mike,

As far as I can understand, you would like to load initially the nodes in the TreeView using a remote call and add new nodes to the widget dynamically at a later stage. If this is the case, you should add the new item using the DataSource.pushCreate() method. That would add the new item to the DataSource locally without trying to syncing its new state with the remote. Here you will find a small sample implementing such scenario.

As per the TreeView load on demand functionality, it is implemented to fit scenarios in which considerable amount of data could be bound to the TreeView. Keep in mind that if too many nodes are expanded and displayed in the browser simultaneously, that would result in considerable amount of DOM elements present in the browser, which may cause some delays in the rendering of the page.

Regards,
Veselin Tsvetanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
TreeView
Asked by
Mike
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Mike
Top achievements
Rank 1
Share this question
or