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

Understanding difference between remote/local datasource

3 Answers 170 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 12 Nov 2014, 05:29 PM
Hi,

I'm trying to understand if what I'm seeing is by design. It appears that when I use a remote HierarchicalDataSource (HDS) with loadOnDemand=false that the datasource "read" method is called for each level of the tree. Is the philosophy here that if you would only use a remote HDS when you have larger datasets to return on demand for different levels of the Hierarchical data? Or, said another way, is it not supported to have a remote HDS return the full structure once and have the TreeView use that and not make any more remote calls (or, use "fetch" at least)?

Alternatively, if I use an HDS with local data with loadOnDemand=false, like:

new kendo.data.HierarchicalDataSource({
    data: someData
})

then the TreeView works with the full data as expected. The trouble here is that I want to provide my data via ajax in one call - not have it called for each level of the tree. And right now it seems I would need to make that ajax call to get the data and then create the HDS as if it is working with local data to avoid all these remote calls.

Am I missing something?

Thanks,
Josh

3 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 14 Nov 2014, 04:26 PM
Hi Josh,

Setting the loadOnDemand option to false forces the TreeView to request all items from the server, essentially populating the entire widget without waiting the user to expand its nodes.
If that is not what happens in your case, then I would ask you to provide a runnable sample project that we can examine.

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Josh
Top achievements
Rank 1
answered on 18 Nov 2014, 03:56 PM
Alexander,

Yes, this is what I'm seeing. My question is, can this work so that the datasource calls the remote service only once (like the 'fetch' method) versus calling it for each node of the tree? Basically, have loadOnDemand=false and have the remote service called once for all the data to populate the tree? Or, does this have to be done manually by getting the data once myself and loading a javascript array into 'data' in a "local" datasource way?

Best,
Josh
0
Alexander Popov
Telerik team
answered on 20 Nov 2014, 12:50 PM
Hello Josh,

Yes, this could be achieved by using a controller method that returns the entire data. Here is a screencast showing a proof of concept example.

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
TreeView
Asked by
Josh
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Josh
Top achievements
Rank 1
Share this question
or