2011-09-14 2 views
0

꽤 여러 MvcContrib 그리드를 정렬하는 구문을 알아낼 수 없습니다. Jeremy Skinner here의 권장 사항은 Bind 속성을 사용하는 것이지만 나는 제대로 이해하지 못합니다. 내가 정말 바인딩 속성에 대한 모든 것을 이해하지 못하는 것 같아요여러 MvcContrib Grid를 정렬하기위한 컨트롤러 구문은 무엇입니까?

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 

아이디어가 있으십니까? 감사.

+0

이 아직 가진 모든 행운? 나는 비슷한 불황을 겪고있다. 다른 사람이 작업을 위해, 당신은 그리드의 각 접두사가 같은 페이지에 정렬 할 설정할 필요가 있음을 아는 –

답변

1

나는 내 게시물에서 내 문제를 알아 냈어 :

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

기본 바인더이 매개 변수를 미리 채우는되지 않고, 그래서 당신의 GridSortoptions 아마 어떤 링크를 궁극적으로 의미하는 null의 가능성이있다.

은 또한, 단지 2 그리드에 대한 제 GridSortOptions 파라미터를 생성하고 정렬하는 호출을 사용하는().

+1

은 도움이 될 수 있습니다. '.Sort ((GridSortOptions)을 ViewData [ "fooSort", "foo는") ' – LOAS

+0

좋은 지적 LOAS : 마찬가지로. –

관련 문제