How to change TD class to MVC3 WebGrid generated output?

I am using MVC3 WebGrid (Razor) and everything is working fine. However, I need to change the css class, which is bound to a specific column based on the value that is in the column.

I have a non-server jquery way to do this already. There are several reasons why I want this to happen outside of jQuery.

Basically, I do highlight / highlight cell traffic based on cell value. Therefore, if the value in cell "62.5", the class that should be bound to <td>is scr60. This sets the background color for the cell to the appropriate hue.

<tr>
  <td class="scr60">62.5</td>
</tr>

I know that I can control the output of the cell contents using the parameter format:in the definition grid.Column(), but I need to set the CSS class for the actual one <td>that contains the content (so that the whole cell is highlighted not only by the value / content itself.

I already have a separate helper class / method for displaying the name of the CSS class that I want to use based on the value. I need a way to edit the style of the containing <td>using the output of this method.

Again, I already have a jQuery solution that does this , I'm looking for a way to do this using the webpage itself.

+3
source share
2 answers

WebGrid , span span , .

+1

'format:', 'style:', :

style: "class1 class2"
-1

All Articles