Welcome Guest, Not a member yet? Register   Sign In
how do you add columns to a table generated with the table library
#1

[eluser]alebenson[/eluser]
i was reading the table libray user guide, an though that this was greate just point to a db table an generate an html table.

that could list the whole posts from a blog in the admin area to edit them or delete
but how can i do that with the libray is that possible?

i.e. listing the all the posts

id |title |text |edit |delete
------------------------------------------------------------------------
1 |sometitleA |txttxttxttxt |edit this post |delete this post
2 |sometitleB |txttxttxttxt |edit this post |delete this post
3 |sometitleC |txttxttxttxt |edit this post |delete this post

where id,title,text comes from a DB, but how do i add the edit and delete links?

i found 2 way of doing it.. just not using the table libray with a froeach or adding the cells with JS

do you know another way?¿
#2

[eluser]Pascal Kriete[/eluser]
I can't test it right now, but in your controller you could try to add a field to your result array.

Something like this:
Code:
//$entries comes from a returned result_array()
foreach ($entries as $post) {
    $url = "path to delete/".$post['id'];
    $post['delete'] = '<a href="'.$url.'">Delete</a>';
}
#3

[eluser]alebenson[/eluser]
hey ho!... finaly went through that i've found that this is a good thing

instead of adding nother thing to the array you can add a TD on the template of the table

Code:
$this->load->library('table');
$tmpl = array (
'row_end' => '<td><a>edit</a></td><td><a>delete</a></td></tr>',
);
$this->table->set_template($tmpl);

buuuuuuuuuuuuuuuuuut...
it is not going to work if you want to add an url with some id or dynamic thing




Theme © iAndrew 2016 - Forum software by © MyBB