ASP.NET MVC grid/table

Posted by nivlam on Stack Overflow See other posts from Stack Overflow or by nivlam
Published on 2011-01-17T04:39:09Z Indexed on 2011/01/17 4:53 UTC
Read the original article Hit count: 309

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?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about mvccontrib