I'm using Kendo Grid to display my data, but when I load 500K records the paging is very slow. When changing a page, the Read function is called resulting a call to the database in which all the 500K records are retrieved each time.
VIEW
@Html.Kendo().Grid<MyViewModel>()
.Name("grid")
.Columns(c=>
{
c.Bound(model => model.UserId);
c.Bound(model => model.UserName);
c.Bound(model => model.Email);
})
.Filterable()
.Sortable()
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("ReadData", "Home").Data("filters"))
.PageSize(30)
)
Controller
public ActionResult ReadData([DataSourceRequest] DataSourceRequest request, string searchText)
{
var data = GetData(searchText).ToList();
return Json(data.OrderBy(x=>x.UserId).ToList().ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
What could I be doing wrong?