Name | Surname | Marital status | Age | Birthday | Employed |
---|---|---|---|---|---|
Joe | Crosswave | Married | 32 | 1/5/1992 | False |
Merry | Lisel | Widowed | 42 | 5/6/1982 | |
Henry | Crux | Single | 30 | 11/19/1994 | True |
[HttpGet]
public ViewResult Index(Int32? page, Int32? rows)
{
IQueryable<Person> people = repository.GetPeople();
// Manual filtering and sorting if enabled.
ViewBag.TotalRows = people.Count();
return View(people.Skip((page - 1 ?? 0) * (rows ?? 3)).Take(rows ?? 3));
}
@model IQueryable<Person>
@(Html
.Grid(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");
})
.Using(GridProcessingMode.Manual)
.Pageable(pager =>
{
pager.TotalRows = ViewBag.TotalRows;
pager.ShowPageSizes = true;
pager.PageSizes.Clear();
pager.RowsPerPage = 3;
})
)