Well, it was a little difficult for me to implement this, so I wanted to show what I did based on the accepted answer. Perhaps this will help you.
grid.Column("Status", "Status", (item) =>
new MvcHtmlString(Html.Encode(item.Status) +
"<div class='color' style='display: none;'>#" + item.RowColor + "</div>"))
I simply extracted the color from my Row object as follows:
public class MyRowType {
public String Status { get; set; }
public String RowColor
{
get{
switch (Status)
{
case "RUNNING":
return "0000FF";
case "FAILED":
return "FF0000";
default:
return "00FF00";
}
}
}
}
The status column was there before, but now the entire row is colored depending on the value in the "Status" field.
Alex source
share