Conditional format of cell
Conditional format of cell
Hi
I am completely new to all this. I have managed to display a table with this javascript:
My table has 8 columns, and the last column has the text "Paid" or "Not Paid". What I would like to do is make this cell background Green if "Paid" and Red if "Not Paid"
Columns:
<
table id="gbintl_entries" class="display" data-page-length='25'>
<thead>
<tr bgcolor="#a8a7a8">
<td><strong>First Name</strong></td>
<td><strong>Last Name</strong></td>
<td><strong>Junior?</strong></td>
<td><strong>Country</strong></td>
<td><strong>Class(es)</strong></td>
<td><strong>Banquet Tickets</strong></td>
<td><strong>Date Entered</strong></td>
<td><strong>Paid?</strong></td>
</tr>
</thead>
I have tried many variations of this:
$('#gbintl_entries').dataTable( {
"createdRow": function( row, data, dataIndex ) {
if ( data[7] == "Paid" ) {
$(row).addClass( 'important' );
}
}
} );
But I don't even know where to put it or where I should put the 'class'
Answers
See if this example helps:
http://live.datatables.net/muyemace/1/edit
Note this is needed for the CSS to highlight the whole row
Kevin
Thank you