Here is my datatables init.
var dataTable = $('#categoriesTable').dataTable(
{
"pageLength": 5,
"lengthMenu": [[5, 10, 25, 50, 100], [5, 10, 25, 50, 100]],
"ajax": {
url: "http://mata.mu/coeg_cms/sempak/posts/categories",
type: "GET"
},
"bSort": false,
"columns" : [
{ "data": "name"},
{ "data": "slug"},
{ "data": "term_taxonomy.description"},
{ "data": "term_id", "render": function(data, type, full, meta){
var delete_url = '<a href="'+$(location).attr('href')+'/'+data+'" class="button small alert expand" data-method="delete" data-reveal-id="myModal'+data+'" data-name="'+name+'">Delete</a>';
return delete_url;
}
}
],
"responsive" : true
});
yes the above code will generate table then add column for action delete
<a href="http://mata.mu/coeg_cms/sempak/posts/categories/71" class="button small alert expand" data-method="delete" data-reveal-id="myModal71" data-name="">Delete</a>
why data-name
attribute is blank ? it should show name from first column ? how to do that ? please correct my render function
The name
variable is not defined. You need to get the value of it using the full
argument that you are passing to your function.
The full
variable represents the data for the entire row. So you can use that to access the name
for that row.
You can probably just do full.name
to get the name.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments