html - 使用 CodeIgniter HTML 表格类,如何添加额外的列?

标签 html codeigniter html-table

添加行似乎很容易,但我想向我的数据中添加带有复选框的列,以便您可以“编辑”或“删除”该行。

有什么 CI 友好的方法可以做到这一点?

最佳答案

像这样手动设置标题和列,在最后一列中插入您需要的任何内容...

$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();

关于html - 使用 CodeIgniter HTML 表格类,如何添加额外的列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5263050/

相关文章:

apache - 实时网络服务器上的 404 Code Igniter

html - 有没有办法清除/隐藏两个 td 表中的第一个 td,而无需访问第一个 td?

jquery - 横向切换导航无法滚动

html - 如何使子 div 始终适合父 div?

html - 隐藏输入图像 URL

php - 尝试将数据插入 mySQL 数据库时卡住

php - MySQL - 创建一个 SQL 算法来确定随机 'popular' 内容

php - 从上层目录导入 CSS 文件

html - 如何防止表格单元格边框从 "bleeding"相互插入

html - 基于 colgroup 的表格单元格的宽度不起作用