CodeIgniter Forums

Full Version: Change layout for specified rows
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

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>'

El Forum

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

<tr class="row5"> </tr>

you get the idea.

El Forum

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

El Forum

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.

El Forum

You may try this method:
(correct me if i misunderstand your question)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
&lt;html xml:lang="en" lang="en"&gt;

&lt;meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /&gt;
&lt;title&gt;Alternating Color&lt;/title&gt;
    &lt;style type="text/css"&gt;

            <th>Alternate Color</th>
        &lt;?php for($i=0;$i<=10;$i++):?&gt;
            <tr class="&lt;?php echo (($i%2)==0) ? "gray" : "green"?&gt;">
                <td>&lt;?php echo (($i%2)==0) ? "gray" : "green"?&gt;</td>
        &lt;?php endfor;?&gt;