ASP.NET MVC grid/table
- by nivlam
public class Person
{
public string First { get; set; }
public string Last { get; set; }
public int Age { get; set; }
public IEnumerable<Child> Children { get; set; }
}
public class Child
{
public string First { get; set; }
public string Last { get; set; }
public int Age { get; set; }
}
I'm searching for a way to render a table from my model, which is of type IEnumerable<Person>. I'm trying to generate the following table:
<table>
<tr class="person">
<td>First 1</td>
<td>Last 1</td>
<td>1</td>
</tr>
<tr class="child">
<td>First 1</td>
<td>Last 1</td>
<td>1</td>
</tr>
<tr class="child">
<td>First 2</td>
<td>Last 2</td>
<td>2</td>
</tr>
...
...
</table>
Each person is a row and each of their children would be individual rows under the person row. This would repeat for each person in IEnumerable<Person>.
Are there any grids or components that generate a table like this? I found MvcContrib's grid component, but it doesn't appear to be able to generate these child rows. Is there a way to extend MvcContrib's grid to do this?