Search results

How to set complex column as Foreignkey column in ASP.NET Core Grid control

19 Oct 2021 / 1 minute to read

The following example shows how to set the complex column as foreign key column.

In the following example, Employee.EmployeeID is a complex column and also declared as a foreign column which shows FirstName column from foreign data.

Copied to clipboard
<ejs-grid id="Grid" dataSource="@ViewBag.DataSource">
        <e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="120"></e-grid-column>
        <e-grid-column field="Employee.EmployeeID" foreignKeyField= "EmployeeID" headerText="Employee Name" foreignKeyValue="FirstName" dataSource="ViewBag.foreign" width="150"></e-grid-column>               
        <e-grid-column field="Freight" headerText="Freight" textAlign="Right" format="C2" width="120"></e-grid-column>               
        <e-grid-column field="ShipName" headerText="Ship Name" width="150"></e-grid-column>
Copied to clipboard
public IActionResult DefaultExporting()
    var order = OrdersDetails.GetAllRecords();
    ViewBag.DataSource = order;

    var emp = EmployeeView.GetAllRecords();
    ViewBag.foreign = emp;
    return View();