MvcContrib Grid - Change multiple row colours based on a value in that row

726 Views Asked by At

I have a mvccontrib grid and need to change the row colours dependant on a cells status value.

I found the following MVC: How can I change a Html.Grid row's colour based on value? very interesting but it only worked for one class, I would like to add a secondary class for another status.

e.g. Active = .green
In-active = .red
Deleted = no class

Thanks in advance.

1

There are 1 best solutions below

0
On
column.For(p => p.a).Atributes(p=>
{
    if (p.Item.Status == "Active")
    {
        return new Dictionary<string, object>{{ "style", "color:green" }};
    }
    else if (p.Item.Status == "In-active")
    {
        return new Dictionary<string, object>{{ "style", "color:red" }};
    }
    return new Dictionary<string, object>();
});