NHibernate paging for Telerik Extensions for ASP.NET MVC
How can I integrate Telerik Grid paging 开发者_运维技巧for ASP.NET MVC (http://demos.telerik.com/aspnet-mvc/Grid) with my NHibernate data access with minimal coding?
Try to pass an IQueryable object (Linq to NHibernate) to Telerik Grid, in this case it will do paging/sorting automatically (no coding required).
I really don't know what your standards for minimal coding are but on Telerik site you provided there's a quite verbose example:
public partial class GridController : Controller
{
public ActionResult FirstLook(bool? ajax, bool? scrolling, bool? paging, bool? filtering, bool? sorting, bool? grouping, bool? showFooter)
{
ViewData["ajax"] = ajax ?? true;
ViewData["scrolling"] = scrolling ?? true;
ViewData["paging"] = paging ?? true;
ViewData["filtering"] = filtering ?? true;
ViewData["grouping"] = grouping ?? true;
ViewData["sorting"] = sorting ?? true;
ViewData["showFooter"] = showFooter ?? true;
return View(GetOrderDto());
}
[GridAction]
public ActionResult _FirstLook()
{
return View(new GridModel(GetOrderDto()));
}
}
So all you need to do is implement this GetOrderDto
method (which by the way should be placed in some repository and not part of the controller logic) in which you would use your existing NHibernate data access.
精彩评论