I am moving my application to MVC 3 and try to use System.Web.Helpers.WebGrid. I would like to get html code like:
<table>
<tr style="background-color: <%= item.Color %>">
</tr>
<tr style="background-color: <%= item.Color %>">
</tr>
<tr style="background-color: <%= item.Color %>">
</tr>
</table>
There is rowStyle
property, that allows to define css class for every row, but there will be different style for every row. Is it achieveable easily?
So I had to finish with hack. First, include color as a part of another column. It had to be returned as
MvcHtmlString
to avoid additional encoding:Then we are setting bacground color in
$(document).ready()
: