EllisLab text mark
Advanced Search
     
Change layout for specified rows
Posted: 04 October 2012 08:19 AM   [ Ignore ]
Joined: 2012-10-04
2 posts

How can I change the layout of specified rows (not all rows) with the HTML Table Class in CodeIgniter? I tried it with the template array, but this effects the entire table respectively all rows.

$tmpl = array (
    
'table_open'          => '<table border="0" cellpadding="4" cellspacing="0">',
    
'heading_row_start'   => '<tr>',
    
'heading_row_end'     => '</tr>',
    
'heading_cell_start'  => '<th>',
    
'heading_cell_end'    => '</th>',
    
'row_start'           => '<tr>',
    
'row_end'             => '</tr>',
    
'cell_start'          => '<td>',
    
'cell_end'            => '</td>',
    
'row_alt_start'       => '<tr>',
    
'row_alt_end'         => '</tr>',
    
'cell_alt_start'      => '<td>',
    
'cell_alt_end'        => '</td>',
    
'table_close'         => '</table>'
);
$this->table->set_template($tmpl); 

 
Posted: 04 October 2012 08:33 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2011-08-08
524 posts

Incorporate CSS, you can use ID or Class.
Class is better.

<tr class="row5"> </tr

you get the idea.

 

 Signature 

Stick with it, practice it and have fun with it.

 
Posted: 04 October 2012 08:57 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2012-10-04
2 posts

all i want to do is to colorize a specific row depending on if Condition

 
Posted: 04 October 2012 08:23 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2007-11-28
2435 posts

The Table library as is does not support that. You’ll need to extend the library to add that feature, or just create the table HTML manually.

 
Posted: 04 October 2012 10:15 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2012-08-12
80 posts

You may try this method:
(correct me if i misunderstand your question)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xml:lang="en" lang="en">

<
head>
 <
meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
 <
title>Alternating Color</title>
    <
style type="text/css">
    .
gray{
        background
:#a3a3a3;
    
}
    
.green{
        background
:#a8fe9f;
    
}
    
</style>
</
head>

<
body>
<
table>
    <
thead>
        <
tr>
            <
th>Alternate Color</th>
        </
tr>
    </
thead>
    <
tbody>
        
<?php for($i=0;$i<=10;$i++):?>
            
<tr class="<?php echo (($i%2)==0) ? "gray" : "green"?>">
                <
td><?php echo (($i%2)==0) ? "gray" "green"?></td>
            </
tr>
        
<?php endfor;?>
    
</tbody>
</
table>
</
body>
</
html