asp.net mvc - Defining inline row style in System.Web.Helpers.WebGrid -


i moving application mvc 3 , try use system.web.helpers.webgrid. 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 rowstyle property, allows define css class every row, there different style every row. achieveable easily?

so had finish hack. first, include color part of column. had returned mvchtmlstring avoid additional encoding:

<%       var grid = new webgrid(model); %> <%=      grid.gethtml(         tablestyle: "table_class",         columns:  grid.columns(             grid.column("importance", ctres.importance, (item) =>                  new mvchtmlstring(html.encode(item.importance) +                  "<div class='color' style='display: none;'>#" + item.color + "</div>"))         )     )  %> 

then setting bacground color in $(document).ready():

<script type="text/javascript">     $(document).ready(         function () {             $('.table_class .color').each(function (index, element) { $(element).parent().parent().css('background-color', $(element).html()); });         }     ); </script> 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -