views:

87

answers:

1

Hi all,

I've been looking around for a solution to this thing but I haven't found anything similar to what I want.

I've got a table filled with data from a database, and I want to change the background colour of a specific row depending on the class I'm loading in each row.

I have to display some data but as the fields to be displayed are quite a lot, I don't have more space to show a status field, so I would like to show the row in red if the status is inactive, and the rest of the rows in the normal color of the blue stylesheet.

Is there a way to do that through tablesorter? I'm open to suggestions, as I'm not sure of how I want to do it.

Thank you all in advance,

Victor

+1  A: 
<style>
      table.even, tr.active td
       {
         background-color:#00F; //BLUE IF ACTIVE
         height:40px;
       }

       table.even, tr.inactive td
       {
         background-color: #F00;//RED IF INACTIVE
         height:40px;
       }
</style>


<table>
    <tr class= (put condition which returns true if active otherwise false)?   "active" : "inactive">


    </tr>
<table>
Salil
I think the SO is using jquery (unless there is another tablesorter). Plus I'm not clear how this addresses the problem. Doesn't he just want one row to a different color?
Anthony
Yes, I'm using jQuery and ASP.NET MVC. The condition depends on the Model I'm passing to the view from the controller, and checking its status loading each row, it has to set the bg colour to red. I'm going to try what you propose. Thank you !
vikitor
Very useful, thanks very much:)
vikitor