Welcome Guest, Not a member yet? Register   Sign In
Change layout for specified rows
#1

[eluser]Unknown[/eluser]
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.

Code:
$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);

#2

[eluser]solid9[/eluser]
Incorporate CSS, you can use ID or Class.
Class is better.

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

you get the idea.
#3

[eluser]Unknown[/eluser]
all i want to do is to colorize a specific row depending on if Condition
#4

[eluser]Aken[/eluser]
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.
#5

[eluser]Beginers[/eluser]
You may try this method:
(correct me if i misunderstand your question)
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html xml:lang="en" lang="en"&gt;

&lt;head&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;
    .gray{
        background:#a3a3a3;
    }
    .green{
        background:#a8fe9f;
    }
    &lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;
<table>
    <thead>
        <tr>
            <th>Alternate Color</th>
        </tr>
    </thead>
    <tbody>
        &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>
            </tr>
        &lt;?php endfor;?&gt;
    </tbody>
</table>
&lt;/body&gt;
&lt;/html&gt;




Theme © iAndrew 2016 - Forum software by © MyBB