[HttpGet]
public ViewResult Index()
{
return View();
}
[HttpGet]
public PartialViewResult IndexGrid(String search)
{
return PartialView("_IndexGrid", repository.Filter(search));
}
<input id="GridSearch" />
@Html.AjaxGrid(Url.Action("IndexGrid"))
<script>
document.getElementById('GridSearch').addEventListener('input', function() {
var grid = new MvcGrid(document.querySelector('.mvc-grid'));
grid.query.set('search', this.value);
grid.reload();
});
</script>
@model IQueryable<Person>
@* Should only include grid declaration *@
@(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");
})
.Empty("No data found")
.Sortable()
)