Name | Surname | Marital status | Age | Birthday | Employed |
---|---|---|---|---|---|
Joe | Crosswave | Married | 32 | 1/5/1992 | False |
Merry | Lisel | Widowed | 42 | 5/6/1982 |
[HttpGet]
public ActionResult Index()
{
// Initial page load would load grid html and then switch to ajax for consecutive calls.
if (HttpContext.Request.Headers.XRequestedWith == "XMLHttpRequest")
return PartialView("_IndexGrid", repository.GetPeople());
return View(repository.GetPeople());
}
@model IQueryable<Person>
@(Html.Partial("_IndexGrid"))
@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");
columns.Add(model => model.IsWorking).Titled("Employed");
})
.UsingUrl(Url.Action("Index", "Home"))
.Empty("No data found")
.Pageable(pager =>
{
pager.PagesToDisplay = 3;
pager.RowsPerPage = 2;
})
.Filterable()
.Sortable()
)