开发者

Sorting Not working in MVC Contrib Grid

i am using mvc contrib grid...........

So far i have used this coding for sorting but it is not working review my code.....

List View:

<%= Html.Grid<Product>(Model)
            .Sort(ViewData["sort"] as GridSortOptions)
            .Columns(column =>
          {

              column.For(c => c.ProductID);
              column.For(c => c.ProductName); 
              column.For(c => c.SupplierID);
              column.For(c => c.CategoryID);
              column.For(c => c.QuantityPerUnit);
              column.For(c => c.UnitPrice);
              column.For(c => c.UnitsInStock);
              column.For(c => c.UnitsOnOrder);
              column.For(c => c.ReorderLevel);
              column.For(c => c.Discontinued);
              column.For(c => Html.ActionLink("Details", "Details", new { id = c.ProductID })).InsertAt(0).Encode(false);
              column.For(c => Html.ActionLink("Edit", "Edit", new { id = c.ProductID })).InsertAt(1).Encode(false);
              column.For(c => Html.ActionLink("Create", "Create", new { id = c.ProductID })).InsertAt(2).Encode(false);
              column.For(c => Html.ActionLin开发者_运维问答k("Delete", "Delete", new { id = c.ProductID })).InsertAt(3).Encode(false);
          }
              )
%>
<p>
    <%= Html.Pager((MvcContrib.Pagination.IPagination)(Model))
    %>
</p>

in my home controller this code:

  public ActionResult Sorting(GridSortOptions Sort)
    {
        using (ProductsDataContext db = new ProductsDataContext())
        {
            var categories = db.Products.ToList();
            if (Sort.Column != null)
                categories = categories.OrderBy(Sort.Column, Sort.Direction).ToList();
            ViewData["sort"] = Sort;
            return View(categories);

        }

    }

either i want to create a separte view for sorting................


Check out this post for a really good example of using MVC Contrib sort, paging and filtering.

it also include downloadable project.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜