Note that there are some explanatory texts on larger screens.

plurals
  1. POMvcContrib Grid Sorting and paging
    primarykey
    data
    text
    <p>seems like I got a trouble when I am using MVCContrib. I am using MVC4 to build a website and I want to show a datagrid that shows all the users My data model is build by ADO.NET Entity Data Model, but I modify it so that I can use it easily in MVC4. When I am trying to implement paging function, it throw an error: "The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'. " source error is on: @Html.Grid(Model).Sort(ViewBag.SortModel as GridSortOptions).Columns(column =></p> <p>I have no idea how to fix this issue. in this case, if I am just using sorting, there is no problem. the issue only appears when I add paging function into the website (PS: I have tried only use paging, but it still giving me the same error).</p> <p>Please help me :)</p> <p>On the controller:</p> <pre><code>public ActionResult Index(int? page, GridSortOptions SortModel) { userRsy = new UserRepository(); if (CookieUserName == "") { return RedirectToAction("Index", "Home"); } else { DBEntities _db = new DBEntities(); //ViewData.Model = _db.Users; ViewBag.SortModel = SortModel; IEnumerable&lt;User&gt; userList = _db.Users; if (!string.IsNullOrEmpty(SortModel.Column)) { userList = userList.OrderBy(SortModel.Column, SortModel.Direction); //userList = userList.OrderBy(u =&gt; u.UserName); } //find login user var _user = userRsy.Find(CookieUserName); //ViewBag.Title = _user.FirstName + ", Welcom to E-Tabs Dashboard Management Center"; //Check user admin level ViewBag.User = _user.FirstName; ViewBag.Account = _user.UserName; ViewBag.IsAdmin = false; if (userRsy.AdminCheck(_user.UserName) == 99) { ViewBag.IsAdmin = true; } //Pagination userList = userList.AsPagination(page ??1,5); //show view return View(userList); } } </code></pre> <p>on the cshtml file:</p> <pre><code>@model IPagination&lt;E_Tabs_Generic_Portal.Models.User&gt; @using MvcContrib.UI.Grid; @using MvcContrib.Pagination; @using MvcContrib.UI.Pager; @using MvcContrib.Sorting; @{ ViewBag.Title = "User"; Layout = "~/Views/Shared/_HomeLayout.cshtml"; } &lt;div class="content-1"&gt; &lt;h2&gt;User List&lt;/h2&gt; @Html.Grid(Model).Sort(ViewBag.SortModel as GridSortOptions).Columns(column =&gt; { column.For(p =&gt; p.UserName).Named("User Name"); column.For(p =&gt; p.IsEnabled).Named("Enabled"); column.For(p =&gt; p.FirstName).Named("First Name"); column.For(p =&gt; p.LastName).Named("Last Name"); column.For(p =&gt; p.Email).Named("E-Mail"); column.For(p =&gt; p.Company).Named("Company"); column.For(p =&gt; p.ServerName).Named("On Server #"); column.For(p =&gt; p.LastLoginTime).Named("Last Login").Format("{0:yyyy/MM/dd HH:mm}"); } ).Attributes( @class=&gt;"Grid",@width =&gt;"100%", @border =&gt;"1", @style =&gt;"text-align:center;border-collapse:collapse") @Html.Pager(Model).First("First").Next("&gt;&gt;").Previous("&lt;&lt;").Last("Last").Format("Total{2}, Current{0}-{1} ") &lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload