This question is locked. New answers and comments are not allowed.
Hi,
So like the title says, I'm trying to implement server side paging and sorting without an ajax call. Code follows:
View
controller:
When my grid loads, it only has one page available when there should be 3. Any help would be greatly appreciated.
John
So like the title says, I'm trying to implement server side paging and sorting without an ajax call. Code follows:
View
@model DataObjects.TestEntryPageWrapper
@(Html.Telerik().Grid(Model.TestEntries) .Name("Grid") .DataBinding(dataBinding => dataBinding.Server() .Select("Index","Notification")) .Pageable(settings => { settings.Enabled(true); settings.Total(Model.TotalRecords); settings.PageTo(Model.Page); settings.PageSize(Model.PageSize); settings.Position(GridPagerPosition.Bottom); }) .Columns(columns => { columns.Bound(o => o.TesterName).Title("Tester"); columns.Bound(o => o.InstitutionID).Title("Inst"); columns.Bound(o => o.IPID).Title("IPID"); columns.Bound(o => o.Category).Title("Category"); columns.Bound(o => o.Description).Title("Description"); columns.Bound(o => o.DateCreated).Title("Date Created").Format("{0:g}"); columns.Bound(o => o.ShortResultText).Title("Result"); columns.Template( @<text>@Html.ActionLink("Load", "Send", new { id = item.ID })|@Html.ActionLink("Details", "Details", new { id = item.ID })|@Html.ActionLink("Delete", "Delete", new { id = item.ID })</text> ).Title("Commands").HtmlAttributes(new { @style = "white-space: nowrap; color: #abc;" }); }) .Scrollable(scrolling => scrolling.Enabled(false)) .Sortable(sorting => sorting.Enabled(true)) .Filterable(filtering => filtering.Enabled(true)) .Groupable(grouping => grouping.Enabled(true)) .Footer(true) )controller:
[GridAction(EnableCustomBinding = true, GridName="Grid")] public ActionResult Index(string filterValue) { int gridPage; int.TryParse(Request["Grid-Page"], out gridPage); if (gridPage == 0) gridPage = 1; int pageSize; int.TryParse(Request["Size"], out pageSize); if (pageSize == 0) pageSize = 20; string orderBy = "DateCreated"; if (!string.IsNullOrEmpty(Request["Grid-orderby"])) orderBy = Request["Grid-orderby"]; //ViewData["FilterValue"] = filterValue; var pageWrapper = new TestEntryPageWrapper() {Page = gridPage, PageSize = pageSize}; using (var db = new STTDataContext()) { pageWrapper.TotalRecords = db.TestEntries.Count(); int startIndex = (gridPage - 1) * pageSize; pageWrapper.TestEntries = db.TestEntries.Skip(startIndex).Take(pageSize).ToList(); return View(pageWrapper); } }When my grid loads, it only has one page available when there should be 3. Any help would be greatly appreciated.
John