We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Render sublists

If I have a list of MarkCollection objects to display in a grid like below:

public class MarkCollection
        public string StudentName { get; set; }
        public IEnumerable Marks { get; set; }

how can I access an object in the sublist?


@Html.EJS().Grid("Marks").DataSource(d =>
    {        d.Url($"/api/attendance/marks/loadRegister/dataGrid/{Model.WeekId}/{Model.Session.Id}").BatchUrl("/api/attendance/marks/saveRegister").CrossDomain(false).Adaptor("UrlAdaptor");
    }).Columns(c =>

        for (int i = 0; i < Model.Periods.Count(); i++)

    }).EditSettings(e => { e.AllowEditing(true).Mode(EditMode.Batch);}).EnableHover().Toolbar(new List() {"Update"}).GridLines(GridLine.Both).Render()

5 Replies

TS Thiyagu Subramani Syncfusion Team August 29, 2019 12:58 PM UTC

Hi Rowan, 
Greetings from Syncfusion support. 
Thanks for your patience. 
We have analyzed the reported query “Render sub lists” at our end. 
Using the below code example, we accomplished your requirement at our end. Please refer the below code example. 
@using gridmvclocalization.Models; 
@Html.EJS().Grid("Complex").DataSource((IEnumerable<object>)ViewBag.LocalData).Columns(col => 
    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(); 
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; 
Please check the sample link and get back to us, if you require any further assistance on this. 
Thiyagu S 

RO Rowan September 16, 2019 03:20 PM UTC


I'm not trying to access multiple properties. "Marks" is a sublist for each of the rows.

I'm trying to access a particular index of "Marks" for each of the columns.

Like this:


TS Thavasianand Sankaranarayanan Syncfusion Team September 17, 2019 11:15 AM UTC

Hi Rowan,  
Thanks for your update. 

In previous update,  we have created a sample for your requirements .In this update we have used complex class EmployeeID and  Country list like your MarkCollection

Please refer the code blocks. 

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; }  
  . . . . .  . 

Grid columns rendered below like this.  

foreach (var prop in filter1.GetType().GetProperties())  
         col.Field("Country."+ prop.Name).Width("120").HeaderText(prop.Name).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).Add();  

You have to achieve your requirement  using the above code blocks. Still your requirement doesn’t met, Please share your  output image and grid rendering code block for further update. 
Note: We suspect your requirement may related to hierarchical binding. In this case refer the below help documentation. 

Please check the sample link and get back to us, if you require any further assistance on this. 
Thavasianand S. 

RO Rowan September 23, 2019 11:47 AM UTC

With hierarchical binding, can I display child data in the parent table? Instead of expanding to show a sub-table

TS Thavasianand Sankaranarayanan Syncfusion Team September 24, 2019 12:56 PM UTC

Hi Rowan, 
Query: With hierarchical binding, can I display child data in the parent table  
From your query we understand that you need to display both parent and child nodes in the same table with hierarchical binding.  This can be achieved using TreeGrid.  
Please refer the below sample,  
Please ensure whether you want to proceed further with the TreeGrid control  

Thavasianand S. 

Live Chat Icon For mobile
Up arrow icon