[Solved] How to add { data: "c.column" } as a variable in defaultcontent:?
[Solved] How to add { data: "c.column" } as a variable in defaultcontent:?
Hello. I am trying to figure out how to add links to the end of rows for things like "view" "edit" "delete". The Delete I will be using the Ajax method, but for view and edit, I want to have it go to a PHP URL. I am currently using CodeIgniter and the CodeIgniter DataTable Library by Paul Zepernick.
Here is my JS so far:
$(function () {
$("#demo-dynamic-tables-2").dataTable({
processing: true,
serverSide: true,
ajax: {
"url": "/customers/dataTable",
"type": "POST"
},
columns: [
{data: "c.name"},
{data: "c.contact"},
{data: "c.phone"},
{data: "c.fax"},
{data: "c.email"},
{data: null, defaultContent: "<span class='bg-linkedin rounded sq-24'><span class='icon icon-eye'></span></span><span class='bg-linkedin rounded sq-24'><span class='icon icon-pencil'></span></span><span class='bg-googleplus rounded sq-24'><span class='icon icon-remove'></span></span>"}
]
});
});
This puts out 3 buttons at the end, an eye (for view) a pencil (for edit) and an X (for delete)
I want the view to go to /customers/view/("c.customer_id") But I have no idea how to implement it. Same for Edit, I want it to link to /customer/edit/("c.customer_id").
Now in my controller I do have the following call:
$this -> load -> library('Datatable', array('model' => 'customer_model', 'rowIdCol' => 'c.customer_id'));
So rowIdCol is already set, but how can I use it?
Answers
Found my answer in the docs.... Have to use render..