Welcome Guest, Not a member yet? Register   Sign In
[Solved] Adding Extra Columns To The HTML Table Library
#2

Use the table template like below:

PHP Code:
$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);


Example table manage method change to suit yourself.

/**
 * manage ()
 * --------------------------------------------------------------------
 *
 * Description:
 *
 * @param    string
 */
public function manage()
{
    
// Grab an array of users from the database
    
$data $this->users->users();

    
// Set table headings
    
$this->table->set_heading('Username''Email''Actions');

    foreach(
$data as $value => $key)
    {
        
// Build the table actions links
        
$actions anchor("admin/users/edit/".$key['id']."/""Edit") . 
                 
  anchor("admin/users/delete/".$key['id']."/""Delete");

        
// Add row to table
        
$this->table->add_row($key['username'], $key['email'], $actions);
    }

    
// Load the view
    
$this->load->view('users/manage');


Hope this helps you.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
RE: Adding Extra Columns To The HTML Table Library - by InsiteFX - 09-17-2016, 03:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB