0

我不太清楚排序多个 MvcContrib 网格的语法。我知道 Jeremy Skinner 的建议使用 Bind 属性,但我就是无法正确使用。

这是我的控制器:

public ActionResult Index([Bind](Prefix="grid1")GridSortOptions sort)\\how do I reference the prefix of my second grid?
{
  ViewData["sort"] = sort;
  var products = _productService.GetAllProducts();
  var categories = _categoryService.GetAllCategories();

  //Here is where I am stuck
  if(sort.Column != null)
   {
     products = products.OrderBy(sort.Column, sort.Direction);
     //how do I reference the sort columns of my second grid?
   }

  var model = new ContainerModel
              {
                Products = products,
                Categories = categories
              };

  return View(model);
}

我想我真的不了解 Bind 属性的所有内容。我尝试添加第二个 GridSortOptions 参数,但没有成功。

如果这有帮助,这是我的看法。

.Sort((GridSortOptions)ViewData["sort"], "grid1")//Grid 1
.Sort((GridSortOptions)ViewData["sort"], "grid2")//Grid 2

有任何想法吗?谢谢。

4

1 回答 1

1

I figured out my problem from my post:

MVCContrib Grid - Sort(GridSortOptions, prefix) not generating links for sorting

It is possible that the default binder is not pre-populating your parameters and so your GridSortoptions are probably null which means no links ultimately.

Also, just create a second GridSortOptions parameter for the second grid and use that in the call to Sort().

于 2011-09-23T18:15:48.887 回答