Welcome Guest, Not a member yet? Register   Sign In
adding class to html table row
#1

[eluser]intsurfer[/eluser]
Hi!
I've changed the Table.php library to set class for rows. I googled how to do it, but i decided to make some changes in the library file.
This is code from my project:
Code:
foreach($res as $item){
//......
$this->table->add_row($item['price'],$celldb,$cellde, $cell1);
$this->table->add_row_class($item['center_id'].'_'.$item['spec_id']);
}
result is:
Code:
<tbody>
<tr class="6_1">
<td>100.00</td><td>01.01.2012</td><td>00.00.0000</td></tr>
<tr class="2_4">
<td>150.00</td><td>01.04.2012</td><td>00.00.0000</td></tr>
</tbody>
File is here
#2

[eluser]InsiteFX[/eluser]
Why, you can create your own Table Template add the class right there.
Code:
&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Class  Admin_Controller
*
* @package  CodeIgniter
* @subpackage Controller
* @category Controllers
* @author  Raymond King aka:(InsiteFX).
* @copyright Copyright (c) 2005 - 2011, Advanced Computer Systems, LLC.
* @license  http://www.learnellislab.com/codeigniter/user-guide/license.html
* @link  http://www.learnellislab.com/codeigniter/user-guide/libraries/name.html
* @since  Version 1.0.0
*/

class Admin_Controller extends Base_Controller {

// --------------------------------------------------------------------

/**
  * Class Variables - protected, private, public and static variables.
  * --------------------------------------------------------------------
  */


// --------------------------------------------------------------------

/**
  * __construct()
  *
  * Constructor PHP 5+
  *
  * @access public
  * @return void
  */
public function __construct()
{
  parent::__construct();

  $this->load->library('table');

  $tmpl = array (
   'table_open'   => '<table border="0" cellpadding="4" cellspacing="0">',

   'thead_open'   => '<thead>',
   'thead_close'   => '</thead>',

   'heading_row_start'  => '<tr>',
   'heading_row_end'  => '</tr>',
   'heading_cell_start' => '<th>',
   'heading_cell_end'  => '</th>',

   'tbody_open'   => '<tbody>',
   'tbody_close'   => '</tbody>',

   'row_start'    => '<tr>',
   'row_end'    => '</tr>',
   'cell_start'   => '<td>',
   'cell_end'    => '</td>',

   'row_alt_start'   => '<tr class="alt">',
   'row_alt_end'   => '</tr>',
   'cell_alt_start'  => '<td>',
   'cell_alt_end'   => '</td>',

   'table_close'   => '</table>'
        );

  $this->table->set_template($tmpl);
}

} // End of Class.


/* ------------------------------------------------------------------------
* End of file Admin_Controller.php
* Location: ./application/core/Admin_Controller.php
* ------------------------------------------------------------------------
*/
#3

[eluser]rip_pit[/eluser]
i think the template will only permit to set odd and even classes but not to specify different custom classes for any row.

if i remember I met the case few weeks ago and had to stop using table helper (no time to develop my own lib)

anyhow it could be a good lib, try publish it in the lib directory in the wiki
https://github.com/EllisLab/CodeIgniter/wiki/
#4

[eluser]intsurfer[/eluser]
[quote author="InsiteFX" date="1342039620"]Why, you can create your own Table Template add the class right there.
[code]
'heading_row_start' => '<tr>',
'row_alt_start' => '<tr class="alt">',
[/quote]
cause i can have 10-10000 with different classes. I use those classes for filtering with JQuery.

Third record - <tr class="6_5">, the next - <tr class="16_1">, etc.
#5

[eluser]intsurfer[/eluser]
[quote author="rip_pit" date="1342044725"]i think the template will only permit to set odd and even classes but not to specify different custom classes for any row.

if i remember I met the case few weeks ago and had to stop using table helper (no time to develop my own lib)

anyhow it could be a good lib, try publish it in the lib directory in the wiki
https://github.com/EllisLab/CodeIgniter/wiki/[/quote]
Thanks for the link! Smile




Theme © iAndrew 2016 - Forum software by © MyBB