【问题标题】:How to add Entity Attributes dynamically to a Grid如何将实体属性动态添加到网格
【发布时间】:2016-12-20 14:50:01
【问题描述】:

我正在尝试将实体属性动态添加到网格中,但出现如下错误。谁能建议我如何动态填充网格。谢谢

@Html.Grid(Model.SearchResults).Columns(columns =>
{                                   
     columns.Add(c => c.Id).Titled("Id");

     foreach (var attribute in Model.SearchResults[0].Attributes)
     {                            
         columns.Add(c => c.Attributes[attribute.Key]).Filterable(true);
     }                        
}).WithPaging(100).Sortable(true)

错误

“System.NotSupportedException”类型的异常发生在 GridMvc.dll 但未在用户代码中处理

附加信息:表达式'c => c.Attributes.get_Item(value(ASP._Page_Views_Queries_ResultGrid_cshtml+c__DisplayClass1).attribute.Key)' 网格不支持

【问题讨论】:

    标签: c# asp.net-mvc asp.net-mvc-4 razor model-view-controller


    【解决方案1】:

    Columns.Add().RenderValueAs(c => c.Attributes[attribute.Key]).Titled("Employee").Filterable(true)

    【讨论】:

      猜你喜欢
      • 2015-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-03
      • 1970-01-01
      • 2011-01-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多