Codeigniter: cambia el diseño de las filas especificadas

How can I change the layout of specified rows (not all rows) with the HTML Table Class in CodeIgniter? I tried it with the template array, but this effects the entire table respectively all rows.

$tmpl = array (
    'table_open'          => '<table border="0" cellpadding="4" cellspacing="0">',
    'heading_row_start'   => '<tr>',
    'heading_row_end'     => '</tr>',
    'heading_cell_start'  => '<th>',
    'heading_cell_end'    => '</th>',
    '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); 

preguntado el 22 de mayo de 12 a las 17:05

1 Respuestas

Sorry to disappoint you, but there's no way to change the layout for specific rows with Codeigniter's HTML Table class. Although the template is customizable, it isn't customizable down to specific rows or cells, it's more useful for just cranking out a quick <table> from an array and is not a complete solution to HTML tables.

Possible solutions without knowing your specific requirements:

  1. Wrap each cell in another element by prepping the input array beforehand (if you just need a .highlighted class or something), which would produce output like this:

    <tr>
      <td><div class="highlight">Data 1</div></td>
      <td><div class="highlight">Data 2</div></td>
      <!-- etc. -->
    </tr>
    
  2. Don't use the Table class at all, but build it the old-fashioned way with HTML, loops and conditionals, which will give you complete control over the layout. (recomendado)

contestado el 22 de mayo de 12 a las 17:05

This is disappointing. Nevertheless, many thanks for your help. I will try the old-fashioned way with HTML. - eichhorn

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.