【发布时间】:2015-06-05 00:40:44
【问题描述】:
[Serializable]
public class ContactDto
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string CompanyName { get; set; }
public Dictionary<string, string> CustomFields { get; set; }
}
我有上面的contactdto 类和自定义字段字典。这些可以是任何“母亲姓名”“生日”等。
如何在剑道网格中将自定义字段显示为列?所有contactDTO 都将具有相同的字典键。我正在使用 ASP.net MVC 助手。
我尝试过类似的方法 - 不起作用 -
@(Html.Kendo().Grid<ContactDto>(Model)
.Name("ReportViewer-Data")
.Columns(columns =>
{
columns.Bound("FirstName");
columns.Bound("LastName");
columns.Bound("CustomFields.Industry");
})
.Sortable()
.Pageable(pageable => pageable.PageSizes(true).ButtonCount(5))
.Groupable()
.Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple))
.Resizable(resize => resize.Columns(true))
.Reorderable(reorder => reorder.Columns(true))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("DataView_Test", "Reports"))
)
)
【问题讨论】:
-
是否要将字典显示为与其他属性相同的网格中的列?还是在第一个网格内的嵌套网格中?你能不能给一些虚拟的json作为例子
-
我想要像 FirstName LastName BirthDate MothersName 这样的列 - 最后两列来自字典
标签: jquery asp.net asp.net-mvc kendo-ui kendo-grid