MVC:如何更改基于价值Html.Grid行的颜色? [英] MVC: How can I change a Html.Grid row's colour based on value?

查看:197
本文介绍了MVC:如何更改基于价值Html.Grid行的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何更改行的颜色在Html.Grid,如果已完成布尔属性等于true。下面是一个例子格:

I was wondering how to change the colour of a row in a Html.Grid, if a 'Completed' boolean property equals true. Here is an example 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");
        })

任何帮助将大大AP preciated。

Any help would be greatly appreciated.

感谢。

推荐答案

我猜你的意思是改变给定行的基于模型属性的给定值电网的背景色。如果是这样,你可以使用 RowAttributes 方法:

I guess you mean changing the background color of a given row in the grid based on a given value of a model property. If so you could use the RowAttributes method:

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

这篇关于MVC:如何更改基于价值Html.Grid行的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆