MVC:如何根据值更改Html.Grid行的颜色?

Big*_*Dom 3 c# asp.net-mvc asp.net-mvc-3

我想知道如果'Completed'布尔属性等于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");
        })
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激.

谢谢.

Dar*_*rov 5

我猜你的意思是根据模型属性的给定值更改网格中给定行的背景颜色.如果是这样,你可以使用这个RowAttributes方法:

@Html.Grid(Model.ExampleList)
     .RowAttributes(row => new Hash(@class => row.Item.IsFoo ? "redclass" : "normalclass"))
     .Columns(c =>
     {
         ...        
     })
Run Code Online (Sandbox Code Playgroud)