CodeIgniter Forums
Using the HTML Table Class - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Using the HTML Table Class (/showthread.php?tid=6774)

Pages: 1 2


Using the HTML Table Class - El Forum - 03-11-2008

[eluser]adamp1[/eluser]
I was just wondering if anyone here uses the HTML table class. Iv been trying to use it but unless you just want a basic table you have to put so much extra code in it doesn't seem worth it.

What about you?


Using the HTML Table Class - El Forum - 03-11-2008

[eluser]Référencement Google[/eluser]
I've been tried it one time, but really found it not enough flexible to suit my needs, then I came back to "manually" built table. It can be good for real simple tables maybe, but I don't use it anyway.


Using the HTML Table Class - El Forum - 03-11-2008

[eluser]sophistry[/eluser]
HTML Table and Calendar classes really need an overhaul. They are weak.


Using the HTML Table Class - El Forum - 03-12-2008

[eluser]Crimp[/eluser]
I am using this class a lot in a current project. Combined with the jQuery tablesorter plug-in, it makes for quick and easy backend sections. A tip is to "cheat" with your template to make the generated table tablesorter compatible, and then you've saved yourself from typing a trillion trs and tds.

Code:
$tmpl = array (
                        'table_open'        => '<table id="' . $table_id . '" cellpadding="0" cellspacing="0" border="0">',
                        'heading_row_start'    => '<thead><tr>',
                        'heading_row_end'    => '</tr></thead><tbody>',
                        'heading_cell_start'=> '<th class="header">',
                        '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'        => '</tbody></table>'
                    );



Using the HTML Table Class - El Forum - 03-12-2008

[eluser]xwero[/eluser]
I have to agree with the majority here, the table class can only be used if you don't have to change the html of the rows and columns when the data asks for it.

@Crimp : why do you use class header? By using the th tag for your cells you already identify them as being in the heading and you also use the thhead tag which is another header identification tag.


Using the HTML Table Class - El Forum - 03-12-2008

[eluser]Crimp[/eluser]
Default for jQuery plug-in, along with .headerSortUp and .headerSortDown.


Using the HTML Table Class - El Forum - 03-12-2008

[eluser]Crimp[/eluser]
I think it's possible to get what you want with js client-side and the added use of ajax. The code becomes more flexible when it's not made up of hundreds of lines of hardcoded HTML.


Using the HTML Table Class - El Forum - 03-12-2008

[eluser]xwero[/eluser]
I rather add classes using php conditions than using js for the conditions. For example
Code:
<td&lt;?php if($row['amountclass'] != ''){ echo ' class="'.$row['amountclass'].'"'; } ?&gt;>&lt;?php echo $row['amount']; ?&gt;</td>
And lets say you have three sorts of amounts you want to emphasize : negative, over thousand, over a million. If you have to do those checks with javascript on a big table you will have to wait a while before every amount is checked.


Using the HTML Table Class - El Forum - 03-12-2008

[eluser]Crimp[/eluser]
You are talking about generating the table in a final state. Look at jQuery for working with the result - a dynamic table. To generate a table server-side with emphasis, you can still use the table class with a single template. Set conditions on a span class in the cell when you want to change the appearance. Each row is simply an array of cell values. It means extra markup, but semantically it's still reasonable; you work with the value, not the container. Using the table class, I now use one template function, one function for a list view and one function for a form view, with a switch for new/edit. That's three private functions to set up and process your CRUD regime in a controller. My days of typing endless tables in a view are over ;-)


Using the HTML Table Class - El Forum - 03-12-2008

[eluser]xwero[/eluser]
I can understand your point of view but i rather go for as little html as possible so i guess we will have a difference of opinion on the subject Smile