我正在使用Grid.Mvc 框架来展示我的模型数据。
开箱即用有两个选项来显示列标题
第一的:
没有资源文件..
//Annotation
[GridColumn(Title = "Active Foo?")]
public bool Enabled { get; set; }
[GridColumn(Title = "Date", Format = "{0:dd/MM/yyyy}")]
public DateTime FooDate { get; set; }
...
//Display the Model items with assigned Column Titles
@Html.Grid(Model).AutoGenerateColumns()
第二:
在视图中使用资源字符串..
//Assign Column Header from
@Html.Grid(Model).Columns(columns =>
{
columns.Add(n => n.Enabled).Titled(DisplayFieldNames.Enabled);
columns.Add(n => n.FooDate).Titled(DisplayFieldNames.FooDate);
})
我想知道如何扩展第一种方法(在模型中使用数据注释)
就像是:
[GridColumn(Title ="Enabled", ResourceType = typeof(DisplayFieldNames))]
和
[GridColumn(Title = "Date", ResourceType = typeof(DisplayFieldNames), Format = "{0:dd/MM/yyyy}")]
里面的ResourceType属性应该使网格在我的资源文件“DisplayFieldNames”中查找列标题