Search results

Complex Data Binding with list of Array Of Objects in ASP.NET MVC Grid control

The following example shows how to set Complex field for datasource having Array Of Objects.

razor
complexarray.cs
@Html.EJS().Grid("Complex").DataSource((IEnumerable<object>)ViewBag.DataSource).Columns(col =>
{
   col.Field("EmployeeID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
   col.Field("Name.0.FirstName").HeaderText("FirstName").Width("140").Add();
   col.Field("Name.LastName").HeaderText("LastName").Width("130").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
   col.Field("City").Width("120").Add();
   col.Field("Country").Width("140").Add();

}).AllowPaging().Render()
public IActionResult Index()
{
    var ComplexData = ComplexData.GetAllRecords();
    ViewBag.DataSource = ComplexData;
    return View();
}