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

Grid with Multiple DataSources

1 Answer 984 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Perry
Top achievements
Rank 1
Perry asked on 07 Mar 2019, 06:13 PM
What is the best practice for a binding a grid to multiple datasources?   I have a grid with a few columns form Rest Endpoint A and the rest of the columns from Rest Endpoint B.  Is there any examples on how to do this?

1 Answer, 1 is accepted

Sort by
0
Accepted
Alex Hajigeorgieva
Telerik team
answered on 11 Mar 2019, 11:58 AM
Hello, Perry, 

The Kendo UI Grid can have a single data source. 

A couple of possible solutions are offered in this forum thread on the same topic:

https://www.telerik.com/forums/multiple-datasources-for-one-grid

You could also possibly define the data source transport read as a function and use the $.when() method, merge the responses and call the success callback

https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/configuration/transport.read

dataSource: {
   transport: {
    read: function(e){
     var callOne = $.ajax({
       url: "/endpointA"
     });
      
     var callTwo = $.ajax({
       url: "/endpointB"
     });
 
     $.when( callOne,callTwo).then(function(firstResponse, secondResponse) {
       var firstResult = firstResponse[0];
       var secondResult = secondResponse[0];
       for(var i=0; i< firstResult.length; i++){
        Object.assign(firstResult[i], secondResult[i]);
       }
       e.success(firstResult);
     });
   }
  }
},

https://dojo.telerik.com/iraDUnEp

Kind Regards,
Alex Hajigeorgieva
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
Data Source
Asked by
Perry
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Share this question
or