Foreign Key Column get Remote Data from Url

Hello

I am using ASP.NET CORE EJ 2 version 16.1.0.34 (nuget package).

I use a grid with Url Adaptor. There is a foreign key column that I can use by passing an object to it.
Is it possible to get the data for the foreign key column remotely by specifying a remote url (as when using the url adaptor for the gird itself)?


Kind regards
Phil

3 Replies

MF Mohammed Farook J Syncfusion Team April 26, 2018 10:24 AM UTC

Hi Phil, 
Thanks for contacting Syncfusion Supports. 
Based on your requirement we have created a sample ‘Grid with UrlAdaptor and ForignKey Column get a dataSource from remote URL’. Please find the code example. 
 
<div> 
    <ejs-grid id="Grid"  allowPaging="true" load="load"> 
        <e-data-manager url="/Home/UrlDatasource" adaptor="UrlAdaptor"></e-data-manager> 
        <e-grid-pagesettings pageCount="5"></e-grid-pagesettings> 
        <e-grid-columns> 
            <e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true"  textAlign="Right" width="120"></e-grid-column> 
            <e-grid-column field="CustomerID" headerText="Contact Name"  width="150" foreignKeyField="CustomerID" foreignKeyValue="ContactName"> 
            </e-grid-column> 
            <e-grid-column field="Freight" headerText="Freight"  textAlign="Right" editType="numericedit" format="C2" width="120"></e-grid-column> 
            <e-grid-column field="ShipCountry" headerText="Ship Country" width="150"></e-grid-column> 
        </e-grid-columns> 
    </ejs-grid> 
</div> 
 
 
We have initialized the remote dataSource for  Foreignkey column by using “load” event of Grid. 
 
 
<script> 
    var data = new ej.data.DataManager({ 
        url: 'http://services.odata.org/V4/Northwind/Northwind.svc/Customers', 
        adaptor: new ej.data.ODataV4Adaptor, 
        crossDomain: true 
    }); 
    function load(args) { 
       this.getColumns()[1].dataSource = data; 
    } 
    </Script> 
 
 
The Grid ‘getColumns()’ method helps to get columns from Grid. Please find the sample and documentation for your reference. 
Documents: 
Regards, 
J.Mohammed Farook 
 



UN Unknown April 27, 2018 02:11 PM UTC

Thank you for your explanation, it works perfectly.


MF Mohammed Farook J Syncfusion Team April 30, 2018 06:17 AM UTC

Hi Phil 

Thanks for your update. We are happy that your issue has been resolved. 

Please let us know if have any queries. 

Regards, 
J.Mohammed Farook

Loader.
Up arrow icon