about td width in Table Library - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: about td width in Table Library (/showthread.php?tid=23822) |
about td width in Table Library - El Forum - 10-22-2009 [eluser]Unknown[/eluser] in ci table, i can't set individual td width. so i try to rewrite Table.php, though i know it's not good to rewrite system code, but it solved my problem. if it's a wrong way or any suggestion, please just tell me. rewrite code as follow, step0-backup Table.php step1-add a width array Code: var $heading_width= array(); step2 -add set_heading_width function Code: function set_heading_width() Code: function clear() in // Build the table rows section rewrite Code: $out .= $this->template['cell_'.$name.'start']; Code: str_replace('>',' width="'.$this->heading_width[$j].'">',$this->template['cell_'.$name.'start']); it will be like this Code: function generate($table_data = NULL) finally load your new as before then add this line , Code: $this->table->set_heading_width('20px', '120px', '150px'); ps. if you don't add the last line, it cause some error, next step, i will add debug code in Table.php about td width in Table Library - El Forum - 10-23-2009 [eluser]sophistry[/eluser] hi seikai and welcome to CI... some parts of CI core are so (ahem) "stable" they barely move at all. viz., i posted a similar upgrade to the table class 2 1/2 years ago. http://ellislab.com/forums/viewthread/50198/ enjoy. about td width in Table Library - El Forum - 01-26-2010 [eluser]Andrew Ul'din[/eluser] thanks! it is work! some update Code: $out .= str_replace('>',' width="'.$this->heading_width[$j].'">',$this->template['cell_'.$name.'start']); change width to style Code: $out .= str_replace('>',' style="'.$this->heading_width[$j].'">',$this->template['cell_'.$name.'start']); like that and you can set any style to the td. for example Code: $this->table->set_heading_width('width: 20px;', 'width: 120px; background: #efefef;', 'cursor: pointer;'); enjoy! |