add a class to particular row in codeigniter using table class
How can I add a class to partic开发者_开发技巧ular row in codeigniter using table class?
You can't add a class to a row in the same way you can added extra attributes to other elements CI-style. You can, however, add a class to every td IN A ROW, and then operate on the class as it references the entire row:
$td1 = array(
'data' => '/*actual html you want in the td*/',
'class' => 'myclass'
);
$table->add_row($td1);
It's annoying to have to do every single td like that, and it isn't really what you want to have to do, but it's the best out there from all the solutions that I've seen.
I would stay away from the CI table class if i were you; it is overly messy and doesnt really make things any easier or save you work.
I prefer this:
<table cellspacing="0" cellpadding="4">
<tr>
<th>Col One</th>
<th>Col Two</th>
<th>Col Three</th>
</tr>
<?php if($table_data != FALSE){?>
<?php foreach($table_data->result() as $row){?>
<tr <?php echo (expr to find the row)? 'class="your_class"' : ''; ?>>
<td></td>
<td></td>
<td><a href="#"></a></td>
</tr>
<?php }?>
<?php }?>
</table>
精彩评论