Nested / combined datasources

2 posts, 0 answers
  1. cra
    cra avatar
    16 posts
    Member since:
    Jun 2012

    Posted 18 Dec 2015 Link to this post

    Hello all,


    Is it possible to created a nested datasource or at least is there a general best practice for combining multiple datasources? Here is my scenario:


    I have an API that exposes some data for an object, a house for instance. A house has various propeties: rooms, bathrooms, etc. For a particular module in our client application we are "searching" for a specific object using an AutoComplete. Once the specific object is view is displayed with the detailed information about the house. In addition in this specific view some additional data is needed, which currently we are combining into one large response object all at once. However it seems that this breaks one of the fundamentals of a RESTful API in that now our /Houses endpoint returns all this related data that is sometimes needed but not always. I have also read that even allowing for related data to be dynamically included at the request of the client information is considered "barely acceptable" which leaves the other option being to make several (4 total in my scenario) requests. Which I have no problem doing in interest of keeping our API "pure". However I would rather not have to "monitor" the completion of each datasource independently then display the form once the last of the datasources has completed. Is there a way to combine the results of my datasources? Could I simply create an observable array that keeps a reference to each datasource?


    Any ideas on this topic would be greatly appreciated.

  2. Alexander Valchev
    Alexander Valchev avatar
    2873 posts

    Posted 23 Dec 2015 Link to this post


    I would recommend to use separate dataSource instances as the dataSource component is designed to work with flat data structures. You may use the filter method and serverFiltering to request data which matches given criteria.

    There is no straightforward way to combine the result of multiple DataSources. Generally speaking you may retrieve the data array of each DataSource instance through the data method and combine them into one array but updating the array would require a lot of code.

    Could I simply create an observable array that keeps a reference to each datasource?

    Not exactly, the DataSource's data is an observable array but if you build an array from it, this array will not automatically update when DataSource is refreshed.

    Alexander Valchev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top