2010-01-08 2 views
0

일반 속성 옆에 속성 값 (속성 모음) 사전이 포함 된 클래스가 있습니다. MvcContrib에서 그리드를 사용하여 테이블에이 개체의 컬렉션을 표시하고 싶습니다.사전 및 목록과 함께 MvcContrib Grid 사용

클래스 :

public class ObjectWithPropertyBag 
{ 
    public string Property1 { get; set; } 
    public string Property2 { get; set; } 

    public Dictionary<string, string> PropertyBag { get; set; } 
} 

내 GridModel (ObjectWithPropertyBagGridModel) :

Column.For(x => x.Property1); 
Column.For(x => x.Property2); 
Column.For(x => x.PropertyBag)//how to display keys as columns and values as table data 

내보기 :

Html.Grid(ViewData.Model.ObjectWithPropertyBag).WithModel(new ObjectWithPropertyBagGridModel()) 

이 사전을 통해 반복하고 열을 만들 수있는 방법이 있나요 ?

감사합니다. 같은

답변

1

뭔가 :

foreach (var prop in PropertyBag) column.For(prop.Value).Named(prop.Key); 

나는 정확한 구문을 기억하지 않지만, 지금까지 내가 기억하는대로 람다를 사용할 필요가 없습니다. 아니면 (. "). Value (prop.Value) ... Grid의 소스 (또는 Google)에 과부하가 있는지 확인하십시오.

+0

코드를 아무리 해킹해도 문제가되지 않습니다. –

관련 문제