about td width in Table Library |
[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
[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.
[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! |
Welcome Guest, Not a member yet? Register Sign In |