[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()
{
$args = func_get_args();
$this->heading_width = (is_array($args[0])) ? $args[0] : $args;
}
step3-rewrite clear()
Code:
function clear()
{
...
// add this line
$this->heading_width = array();
...
}
step3-rewrite generate()
in
// Build the table rows section
rewrite
Code:
$out .= $this->template['cell_'.$name.'start'];
to
Code:
str_replace('>',' width="'.$this->heading_width[$j].'">',$this->template['cell_'.$name.'start']);
it will be like this
Code:
function generate($table_data = NULL)
{
...
// Build the table rows
if (count($this->rows) > 0)
...
$j = 0; // add this line
foreach($row as $cell)
{
//$out .= $this->template['cell_'.$name.'start']; // replace this line as follow
$out .= str_replace('>',' width="'.$this->heading_width[$j].'">',$this->template['cell_'.$name.'start']);
...
$out .= $this->template['cell_'.$name.'end'];
$j++; // add this line here
}
}
finally load your new as before
then add this line ,
Code:
$this->table->set_heading_width('20px', '120px', '150px');
you will get a widthize table
ps. if you don't add the last line, it cause some error, next step, i will add debug code in Table.php