我想知道如果“已完成” bool 属性等于 true,如何更改 Html.Grid 中一行的颜色。这是一个示例网格:
@Html.Grid(Model.ExampleList).Columns(c =>
{
c.For(a => string.Format("{0:dd/MM/yyyy}", a.DateRequested)).Named("Date Requested");
c.For(a => a.Comment).Named("Comment");
c.For(a => a.Completed).Named("Completed");
})
如有任何帮助,我们将不胜感激。
谢谢。
最佳答案
我猜你的意思是根据模型属性的给定值更改网格中给定行的背景颜色。如果是这样,您可以使用 RowAttributes
方法:
@Html.Grid(Model.ExampleList)
.RowAttributes(row => new Hash(@class => row.Item.IsFoo ? "redclass" : "normalclass"))
.Columns(c =>
{
...
})
关于c# - MVC : How can I change a Html. 网格行的颜色基于值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6243889/