public virtual JsonResult DynamicGridData(int page, int rows, string search, string sidx, string sord) { int pageIndex = Convert.ToInt32(page) - 1; int pageSize = rows; ICriteria searchCriteria = pageLocaleService.GetSearchCriteria(search, true); long totalRecords = pageLocaleService.Count(searchCriteria); var totalPages = (int)Math.Ceiling((float)totalRecords / pageSize); var pages = searchCriteria.SetMaxResults(pageSize).SetFirstResult(pageIndex * pageSize).AddOrder(sord == "asc" ? Order.Asc(sidx) : Order.Desc(sidx)).List <PageLocale>(); var jsonData = new { total = totalPages, page, records = totalRecords, rows = (pages.Select(pageLocale => new { id = pageLocale.Page.Id, cell = new[] { pageLocale.Title, pageLocale.Page.Url, pageLocale.Page.HideInMainMenu ? Translate("Boolean.False") : Translate("Boolean.True"), String.Format(JqGridConstants.UrlTemplate, Url.Action(MVC.PageTemplates.Show(pageLocale.Page.Url)), Translate("Actions.View")), String.Format("<a href=\"{0}\"><em class=\"delete\" style=\"margin-left: 10px;\"/></a>", Url.Action(MVC.Admin.PageTemplate.Remove(pageLocale.Page.Id))) } }).ToArray()) }; return(Json(jsonData)); }
public virtual JsonResult DynamicGridData(int page, int rows, string search, string sidx, string sord) { int pageIndex = Convert.ToInt32(page) - 1; int pageSize = rows; ICriteria searchCriteria = pageLocaleService.GetSearchCriteria(search, false); long totalRecords = pageLocaleService.Count(searchCriteria); var totalPages = (int)Math.Ceiling((float)totalRecords / pageSize); var pages = searchCriteria.SetMaxResults(pageSize).SetFirstResult(pageIndex * pageSize).AddOrder(sord == "asc" ? Order.Asc(sidx) : Order.Desc(sidx)).List <PageLocale>(); var jsonData = new { total = totalPages, page, records = totalRecords, rows = (pages.Select(pageLocale => new { id = JqGridConstants.NotClickableId, cell = new[] { pageLocale.Title, pageLocale.Page.Url, pageLocale.Page.HideInMainMenu ? Translate("Boolean.False") : Translate("Boolean.True"), pageLocale.Page.Template != null? pageLocale.Page.Template.Title : String.Empty, String.Format(JqGridConstants.UrlTemplate, Url.Action(MVC.Pages.Show(pageLocale.Page.Url)), Translate("Actions.View")) } }).ToArray()) }; return(Json(jsonData)); }