我不能完全弄清楚排序多个MvcContrib网格的语法。我知道Jeremy Skinner here的建议是使用Bind属性,但我无法正确理解。排序多个MvcContrib网格的控制器语法是什么?
这里是我的控制器:
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);
}
我想我真的不理解的绑定属性的一切。我尝试添加第二个GridSortOptions参数,但没有成功。
这是我的看法,如果这有帮助。
.Sort((GridSortOptions)ViewData["sort"], "grid1")//Grid 1
.Sort((GridSortOptions)ViewData["sort"], "grid2")//Grid 2
任何想法?谢谢。
还有什么运气呢?我也有类似的困境。 –