How to bind data from multiple Odata Endpoints?

Hello Experts,

Is there a way to bind data from multiple endpoints to a pivot table given that the data is related?

5 Replies 1 reply marked as answer

SN Sivamathi Natarajan Syncfusion Team September 22, 2020 03:58 PM UTC

 
Thanks for contacting Syncfusion support. 
 
We have checked the reported problem at our end. But we cannot directly connect multiple end points in pivot table. Instead you can combine two raw data using ODataAdaptor and assign to pivot data source. Please check the code example below. 
 
Code Example: 
<script> 
    function created(args) { 
        var dataSource1, dataSource2; 
        var pivotdata1 = new ej.data.DataManager({ 
            url: 'https://js.syncfusion.com/demos/ejServices/Wcf/Northwind.svc/Orders/', 
            adaptor: new ej.data.ODataAdaptor, 
            crossDomain: true 
        }).executeQuery(new ej.data.Query().take(8)).then(function (e) { 
            dataSource1 = e.result; 
        }); 
        var pivotdata2 = new ej.data.DataManager({ 
            url: 'https://bi.syncfusion.com/northwindservice/api/orders', 
            adaptor: new ej.data.ODataAdaptor, 
            crossDomain: true 
        }).executeQuery(new ej.data.Query().take(8)).then(function (e) { 
            dataSource2 = e.result.Items; 
            var pivotObj = document.getElementById('pivotview').ej2_instances[0]; 
             Array.prototype.push.apply(dataSource1, dataSource2); 
            pivotObj.dataSourceSettings.dataSource = dataSource1; 
        }); 
    } 
 
</script> 
 
 
Please let us know if you have concern. 
 
Regards, 
Sivamathi.

Marked as answer

PB Priyank Bhavsar September 22, 2020 06:20 PM UTC

Hi Sivamathi,

I tried to run your sample but got these errors.




SN Sivamathi Natarajan Syncfusion Team September 23, 2020 12:26 PM UTC

Hi Priyank Bhavsar, 
 
Kindly disable web security in chrome using below comment. Then run the application in the newly opened chrome window. 
 
chrome.exe --disable-web-security --user-data-dir=c:\my-chrome-data\data 
 
Please let us know if you have concern. 
 
Regards, 
Sivamathi. 



PB Priyank Bhavsar September 23, 2020 05:33 PM UTC

Thanks for the reply Sivamathi. It worked.

Can you please let me know if it is possible to group fields in a field list by datasource it belongs to?

For example, I have combined data from two data sources Employee and Department.

Can I show the fields in the field list in two groups Employee and Department so that user can know a field belongs to which data source?






SN Sivamathi Natarajan Syncfusion Team September 24, 2020 09:48 AM UTC

 
We regret you to let you know that the requirement – “To display the fields in field list in groups” couldn’t be achievable in pivot table component. Because the current architecture of the component doesn’t allows to do the customization. So, we suggest you to merge the both data sources then bind it to the component. 
 
Regards, 
Sivamathi.  


Loader.
Up arrow icon