简体   繁体   English

使用CodeIgniter HTML表类,如何添加其他列?

[英]Using the CodeIgniter HTML Table Class, how can I add additional columns?

Adding rows seems to be easy enough, but I want to add columns to my data that have checkboxes so you can "edit" or "delete" that row. 添加行似乎很容易,但是我想在数据中添加具有复选框的列,以便您可以“编辑”或“删除”该行。

Any CI friendly way to do that? 有没有CI友好的方式可以做到这一点?

Manually set your headings and columns inserting whatever you need in your last column like so... 手动设置标题和列,将您需要的内容插入到上一列中,如下所示:

$this->table->set_heading('Heading One', 'Heading Two', ... , 'Links'); //set your headings

foreach($data_rows as $row) { //set your rows here

    // first build links for this row assuming you need the urls to
    // look like 'http://domain/index.php/controller/{action}/{id}
    $links  = anchor('controller/edit/'.$row->id ,'Edit');
    $links .= anchor('controller/delete/'.$row->id , 'Delete');

    $this->table->add_row(
        $row->heading_one,
        $row->heading_two,
        ...,
        $links,   //add the links you created to the last row, corresponding to your 'Links' Header
    );
}

echo $this->table->generate();
 **Error in code : Cannot use object of type mysqli as array in
 C:\xampp\htdocs\CodeIgniter-3.0.6\application\views\admin.php on line 8**
<?php 
 $table_property = array('table_open' => '<table cellpadding="2" cellspacing="1" class="table table-hover">');
  $this->table->set_heading('#Id','Username','Password','Name','Edit','Delete');
  $this->table->set_template($table_property);
  $new=$this->db->query("select * from tbl_admin");

  foreach($new as $row) {
  $links  = anchor('admin/edit/'.$row['User_ID'] ,'Edit');
  $links .= anchor('admin/delete/'.$row['User_ID'] , 'Delete');


$this->table->add_row(
    $row->User_ID,
    $row->Username,
    $row->Password,
    $row->Full_Name,
    $links
    );
}
echo $this->table->generate();

?> ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM