Welcome Guest, Not a member yet? Register   Sign In
Change <td> width when using table class
#1

[eluser]max123[/eluser]
I want to have different <td> widths for different columns. How can i do it using table class. That class allows only to give a fixed <td> width for all <td> s.

Thanx
#2

[eluser]theprodigy[/eluser]
well, you can always extend the table class with your own version that allows you to pass in a td width (or array of options), or you can hand-code your tables. Other than those two options, I personally won't be able to help you as I haven't used that class before.
#3

[eluser]flaky[/eluser]
http://ellislab.com/codeigniter/user-gui...table.html

section: Changing the Look of Your Table
#4

[eluser]elambiguo[/eluser]
[quote author="flaky" date="1263906523"]http://ellislab.com/codeigniter/user-gui...table.html

section: Changing the Look of Your Table[/quote]

flaky, the standard Table Class only permit one change for all <td>... the best option is make tables by hand or extend the original Class......
#5

[eluser]elambiguo[/eluser]
[quote author="max123" date="1263903348"]I want to have different <td> widths for different columns. How can i do it using table class. That class allows only to give a fixed <td> width for all <td> s.

Thanx[/quote]

I have the same problem, and my solution (whitout complications) is hand-coded tables :-(

The answer of @theprodigy is good too....
#6

[eluser]max123[/eluser]
How can we inform these kind of issues to the codeigniter developers. So that they can fix this in the next release
#7

[eluser]elambiguo[/eluser]
[quote author="max123" date="1263917451"]How can we inform these kind of issues to the codeigniter developers. So that they can fix this in the next release[/quote]

Find for 'codeigniter 2.0' or 'codeigniter 2.1' in forums....
#8

[eluser]Unknown[/eluser]
Simple solution works for me (based on the example in the CI manual):
Basically, when setting the table template, set the 'heading_cell_start' tag to <th> = ''. (i.e. empty string)
In the set_heading function include the <th> tags with width attributes when setting the header fields.
I usually also set the 'heading_cell_end' tag to empty as well although it's not really necessary - I just personally find the header declaration easier to read when both opening and closing tags are in the set_heading function's field.

Example (in a controller):

Code:
$this->load->library('table');
$query = $this->db->query("SELECT `name`,`description` FROM my_table");
$this->table->set_heading('<th width="75">Name</th>', '<th width="150">Description</th>');
$tmpl = array (
              'table_open'          => '<table border="1" cellpadding="4" cellspacing="0">',
              'heading_row_start'   => '<tr>',
              'heading_row_end'     => '</tr>',
              'heading_cell_start'  => '',
              'heading_cell_end'    => '',
              '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'         => '</table>'
              );
$this->table->set_template($tmpl);
echo $this->table->generate($query);

Cheers




Theme © iAndrew 2016 - Forum software by © MyBB