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

Sha*_*oon 1 html codeigniter html-table

添加行似乎很容易,但我想在我的数据中添加具有复选框的列,以便您可以"编辑"或"删除"该行.

任何CI友好的方式来做到这一点?

jon*_*ohn 10

手动设置标题和列,在最后一列中插入所需的内容,如此...

$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();
Run Code Online (Sandbox Code Playgroud)