I am working on an asp.net mvc web application, and I want to use the Grid.MVC plugin found at this link http://gridmvc.codeplex.com/ . So I did the following:-
From the NuGet package I installed the Grid.MVC to my project.
The I added the following to my view:-
@model IEnumerable<WebApplication30.Models.Employee>
@using GridMvc.Html
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<div style="width:500px;">
@Html.Grid(Model).Columns(columns =>
{
columns.Add(c => c.FName).Titled(Html.DisplayNameFor(model => model.FName).ToString()).Filterable(true);
columns.Add(c => c.LName).Titled(Html.DisplayNameFor(model => model.LName).ToString()).Filterable(true);
columns.Add(c => c.Dept.DeptName).Titled("deptname").Filterable(true);;
}).WithPaging(3).Sortable(true)
</div>
The model looks as follow:-
public partial class Employee
{
public int Id { get; set; }
[Display(Name = "First Name")]
public string FName { get; set; }
[Display(Name = "Last Name")]
public string LName { get; set; }
public int DeptID { get; set; }
public virtual Dept Dept { get; set; }
}
And the controller is:-
public ActionResult Index()
{
var employees = db.Employees.Include(e => e.Dept);
return View(employees.ToList());
}
Now the paging + column sorting is working well. But I am facing these issues with them:-
Paging + column sort will lead to full page re-load. So can I specify Ajax based interaction?
Paging+ column sort will be done on the client side, so each time I visit the view, I will be retrieving the whole data from the database . so is there a way to do this on the server side.