Understanding difference between remote/local datasource

4 posts, 0 answers
  1. Josh
    Josh avatar
    72 posts
    Member since:
    Jun 2013

    Posted 12 Nov 2014 Link to this post

    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

  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 14 Nov 2014 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Josh
    Josh avatar
    72 posts
    Member since:
    Jun 2013

    Posted 18 Nov 2014 in reply to Alexander Popov Link to this post

    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
  5. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 20 Nov 2014 Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready