• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
<colgroup>, <tfoot> to library Table.php ?

#1
[eluser]Jaketoolson[/eluser]
For css styling purposes, I rely on <colgroup> in my tables to zebra stripe my table columns. Your Table.php library lacks code inserting <colgroup /> into the table structure. While I'm on the subject, it has <thead> code but is also lacking <tfoot>. I just thought it would be nice if you consider including them in the library function to be me complete and thorough.

I added the following code to the table library right after the table headings are generated:
Code:
for($i=0;$i<=$total_rows;$i++)
{
   $out .= $this->template['colgroup'];
   $out .= $this->newline;    
}

And then of course to the _default_template function, I added the following code to the array:
Code:
'colgroup'     => '<colgroup></colgroup>',


One thing I'm excited about is the ability to apply a function to the cell data! This is EXACTLY what I needed and it didn't exist in the previous version of CI and I therefore was filtering the data before the table was generated. Now I can just run the callback function at the cell level. Thanks!

#2
[eluser]dansmith65[/eluser]
I was also surprised to not see an option for adding a <colgroup>. I used this method to 'trick' CI into adding a <colgroup>...
Code:
$tmpl = array(
    'table_open' => '<table><colgroup><col class="col1"/><col class="col2"/></colgroup>',
);

Also, I can't seem to find a way to make the text in a column bold. <colgroup> does not support the font-weight style, and I don't see any way in the table class to target the <td> of a particular column.
The only way I can think is to add a <span> to the data in a column, before adding it to the table.

Is there a better way? If not, I'd love to see that option in a future release of CI.

#3
[eluser]Jaketoolson[/eluser]
Interesting, I did not realize <colgroup> didn't support the font-weight style. Couldn't you achieve the same thing using jQuery?

Code:
$('table td:odd').addClass('bold');

#4
[eluser]dansmith65[/eluser]
Thanks for that. I hadn't thought about using javascript to add a class. I'd prefer to not have to, but that does seem like the easiest method.

#5
[eluser]Jaketoolson[/eluser]
I use colgroups to style my column background colors, but never thought about using font style's and never came across this ! But the jQuery method is the only thing that came to mind.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.