Introduction
When building web applications, we often need to display data in a table format with features like:
Paging
Sorting
Filtering
Editing
Instead of writing complex code, we can use Kendo UI Grid.
Kendo Grid is a powerful UI component that helps display data easily with built-in features.
In this article, we will learn:
What Kendo Grid is
Why we use it
How to use Kendo Grid in MVC using Helpers
All important features with simple examples
What is Kendo Grid?
Kendo Grid is a UI component from Progress Telerik that helps display data in a table with advanced features.
Why Use Kendo Grid?
✔ No need to write complex JavaScript
✔ Built-in features (paging, sorting, filtering)
✔ Clean UI
✔ Easy to use with MVC
Step 1: Create Model
public class Student
{
public int StudentId { get; set; }
public string StudentName { get; set; }
public string City { get; set; }
}Step 2: Controller Code
public class StudentController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult GetStudents()
{
List<Student> list = new List<Student>()
{
new Student{ StudentId=1, StudentName="Abhay", City="Ahmedabad"},
new Student{ StudentId=2, StudentName="Rahul", City="Surat"},
new Student{ StudentId=3, StudentName="Amit", City="Rajkot"}
};
return Json(list, JsonRequestBehavior.AllowGet);
}
}Step 3: Add Kendo Grid in View (Using Helpers)
@(Html.Kendo().Grid<Student>()
.Name("StudentGrid")
.Columns(columns =>
{
columns.Bound(p => p.StudentId).Title("ID");
columns.Bound(p => p.StudentName).Title("Name");
columns.Bound(p => p.City).Title("City");
})
.Pageable()
.Sortable()
.Filterable()
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("GetStudents", "Student"))
)
)What is this?
Output
Grid will show:
ID Name City
1 Abhay Ahmedabad
2 Rahul Surat
3 Amit RajkotWith:
✔ Paging
✔ Sorting
✔ Filtering
Join the conversation! Your thoughts help the community grow.