Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
146983 | Aug 27,2019 03:17 PM UTC | Sep 24,2019 12:56 PM UTC | ASP.NET MVC - EJ 2 | 5 |
![]() |
Tags: Grid |
@using gridmvclocalization.Models;
@Html.EJS().Grid("Complex").DataSource((IEnumerable<object>)ViewBag.LocalData).Columns(col =>
{
col.Field("EmployeeID").Width("120").HeaderText("EmployeeID").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).Add();
Country filter1 = new Country();
foreach (var prop in filter1.GetType().GetProperties())
{
col.Field("Country."+ prop.Name).Width("120").HeaderText(prop.Name).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).Add();
}
}).AllowPaging().Render() |
public ActionResult Index()
{
ViewBag.LocalData = Complex.GetData();
return View();
} |
public class Country
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string CountryName { get; set; }
public int OrderID { get; set; }
}
public class Complex
{
public int EmployeeID {get; set; }
public Country Country { get; set; }
public static List<Complex> GetData()
{
List<Complex> Data = new List<Complex>();
Data.Add(new Complex() { EmployeeID = 10001, Country = new Country() { CountryName = "Australia", FirstName = "ANATR", LastName = "HANAR", OrderID = 10248 } });
Data.Add(new Complex() { EmployeeID = 10002, Country = new Country() { CountryName = "Bermuda", FirstName = "VINET", LastName = "CHOPS", OrderID = 10249 } });
.
.
.
.
.
});
return Data;
}
} |
public class Country
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string CountryName { get; set; }
public int OrderID { get; set; }
} |
public class Complex
{
public int EmployeeID {get; set; }
public Country Country { get; set; }
. . . . . .
}
|
foreach (var prop in filter1.GetType().GetProperties())
{
col.Field("Country."+ prop.Name).Width("120").HeaderText(prop.Name).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).Add();
}
|
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.