This project is read-only.

Allow server side and Ajax filtering & sorting using Grid.MVC

Jan 8, 2015 at 1:43 PM
I am working on an mvc web application, and I want to use the Grid.MVC plugin found at this link . So I did the following:-
  • Inside the Visual studio 2013, 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";


    @Html.ActionLink("Create New", "Create")
<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);;
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.
so can anyone adivce how i can add ajax-based + server side processing for the Grid.MVC?