Name | Surname | Marital status | Age | Birthday | Employed | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Joe | Crosswave | Married | 36 | 1/5/1988 | False | ||||||||||||
|
|||||||||||||||||
Merry | Lisel | Widowed | 46 | 5/6/1978 | |||||||||||||
Henry | Crux | Single | 34 | 11/19/1990 | True | ||||||||||||
Cody | Jurut | 54 | 8/11/1970 | False | |||||||||||||
Simon | Scranton | Single | 39 | 10/10/1985 | |||||||||||||
Leena | Laurent | Divorced | 24 | 7/1/2000 | False | ||||||||||||
Ode | Cosmides | Married | 58 | 4/17/1966 | True | ||||||||||||
|
|||||||||||||||||
Diandra | Mizner | Single | 25 | 8/20/1999 | False | ||||||||||||
Pete | Cassel | Married | 27 | 3/13/1997 | False | ||||||||||||
Nicky | Tremblay | Married | 36 | 1/5/1988 | True | ||||||||||||
|
@model IQueryable<Person>
@(Html
.Grid("_NestedPersonGrid", Model)
.Build(columns =>
{
columns.Add(model => model.Name).Titled("Name");
columns.Add(model => model.Surname).Titled("Surname");
columns.Add(model => model.MaritalStatus).Titled("Marital status");
columns.Add(model => model.Age).Titled("Age");
columns.Add(model => model.Birthday).Titled("Birthday").Formatted("{0:d}");
columns.Add(model => model.IsWorking).Titled("Employed");
})
)
@model IGrid<Person>
<div class="mvc-grid">
<table>
<thead>
<tr>
@foreach (IGridColumn column in Model.Columns)
{
<th>
<span class="mvc-grid-title">@column.Title</span>
</th>
}
</tr>
</thead>
<tbody>
@if (Model.Rows.Any())
{
foreach (IGridRow<Person> row in Model.Rows)
{
<tr class="@row.CssClasses">
@foreach (IGridColumn column in Model.Columns)
{
<td class="@column.CssClasses">@column.ValueFor(row)</td>
}
</tr>
if (row.Model.Children.Any())
{
<tr>
<td colspan="@Model.Columns.Count()">
@(Html
.Grid("_NestedPersonGrid", row.Model.Children)
.Build(columns =>
{
columns.Add(model => model.Name).Titled("Child name");
columns.Add(model => model.Age).Titled("Age");
columns.Add(model => model.Birthday).Titled("Birthday").Formatted("{0:d}");
})
)
</td>
</tr>
}
}
}
else
{
<tr class="mvc-grid-empty-row">
<td colspan="@Model.Columns.Count()">
@Model.EmptyText
</td>
</tr>
}
</tbody>
</table>
</div>