Set complex column as Foreignkey column
17 Feb 20221 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.
<ejs-grid id="grid" dataSource="@ViewBag.DataSource" height="348px">
<e-grid-columns>
<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.EmployeeData" 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>
</e-grid-columns>
</ejs-grid>
public IActionResult DefaultExporting()
{
ViewBag.DataSource = OrdersDetails.GetAllRecords();
ViewBag.EmployeeData = EmployeeView.GetAllRecords();
return View();
}