CodeIgniter Forums
CI table class - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: CI table class (/showthread.php?tid=28635)



CI table class - El Forum - 03-17-2010

[eluser]mjstenbe[/eluser]
Is it possible to customize table template to include db variables such as row and cell numbers as id's or classes and so? I noticed that template only has one beginning tag for tr's and td's, but what if i'd like to change the class for each?

What Im hoping to produce is something like:

Code:
<table>
<tr class="1">
            <td class="id_cell">38</td>
            <td class="1">sdfsdf</td>
            <td class="2"></td>
            <td class="3">sdf</td>
</tr>
<tr class="2">
  <td class="id_cell">39</td>
            <td class="1">sdfsdf</td>
            <td class="2"></td>
            <td class="3">sdf</td>
</tr>
</table>

Thanks,
Mika


CI table class - El Forum - 03-17-2010

[eluser]Maglok[/eluser]
You can do alternating classes like so:
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);
See user_guide: http://ellislab.com/codeigniter/user-guide/libraries/table.html

I take it you want more customization, I personally use some custom code then because the table class isn't that expansive.