模型:
[Display(Name = "Status")]
public bool IsApproved { get; set; }
在视图中:
@Html.Grid(Model.Users).Sort(Model.GridSortOptions).Columns(column =>
{
column.For(ulv => ulv.Name);
column.For(ulv => ulv.SurName);
column.For(ulv => ulv.IsApproved.Equals(true) ? "Approved" : "Not Approved").Sortable(false);
})
Dismplay name“status” - 未显示。列名为空
答案 0 :(得分:1)
因为您没有在column.For
属性上执行IsApproved
,而是在字符串"Approved"
或"Not Approved"
上执行此操作。
您需要将其他属性添加到视图模型并进行装饰:
public bool IsApproved { get; set; }
[Display(Name = "Status")]
public string IsApprovedString
{
get { return this.IsApproved ? "Approved" : "Not Approved"; }
}