How to style rows in the MVCContrib Grid based on their data?

◇◆丶佛笑我妖孽 提交于 2019-12-02 23:51:41
Dan Ryan

Hello Scott: Try something like the following to add RowAttributes -

@Html.Grid(Model)
    .WithModel(new CustomerGridModel())
    .Sort(ViewData["sort"] as GridSortOptions)
    .Attributes(id => "grid", style => "width: 100%;")
    .RowAttributes(data => new MvcContrib.Hash(
        @class => data.Item.Discontinued ? "discontinued" : ""))

This will add a class attribute to the tr element. Then, create a class along the lines of:

tr.discontinued td {background-color: red;}

Sorry for the long code snippet...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!