Search results

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

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">
        <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>
public IActionResult DefaultExporting()
    var order = OrdersDetails.GetAllRecords();
    ViewBag.DataSource = order;

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