2 columnDefs
2 columnDefs
database columns: id, name, released, rating, link
php displays all columns with the link column (https://___)
In html I am doing this - <a href="link">name</a>
I have that working with the code below. Next I want to hide the id and link columns and found this code - "columnDefs" : [
//hide the first & fifthcolumn
{ "visible": false, "targets": [0,4] }
]
How can I add that code to the columnDefs below?
Or simply hide id and link column (since the URL is behind the name)
$(document).ready(function() {
$('#mastertable').dataTable(
{
"order": [[2, 'desc']],
"paging": true,
"scrollCollapse": true,
"scrollY": '80vh',
"lengthMenu": [ [ 100, 250, 500, 1000, -1], [ 100, 250, 500, 1000, "All"] ],
"columnDefs":
[
{ "targets": 1,"data": "download_link","render": function ( data, type, row, meta )
{
return '<a href="'+row[4]+'">'+data+'</a>';
}
}
]
} )
} );
This question has an accepted answers - jump to answer
Answers
The
columnDefs
is an array of options, see the docs for examples. You combine the two, inside the array, with a comma separating them, like this:Kevin