How to have multiples collumDefs?
How to have multiples collumDefs?
User123456
Posts: 57Questions: 15Answers: 0
I need to have 4 buttons. Two in the first collum, and two in the last. Howerever the way I'm doing, all of them appears in the first collum.
What I'm doing wrong?
This is my code:
$(document).ready(function() {
$('#companyTable').DataTable({
"processing": true,
"serverSide": true,
"ajax": "lib/server_processing.php",
"columns": [
{ "data": 0 },
{ "data": 1 },
{ "data": 2 },
{ "data": 3 },
{ "data": 4 },
{ "data": 5 }
],
"order": [ 1, "asc" ],
"columnDefs": [
{ "orderable": false, "targets": 0 },
{ "orderable": false, "targets": 6 },
{
"targets": [6],
"data": "",
"mRender": function ( data, type, full ) {
return '<a data-toggle="modal" data-target="#infoModal" id="getPublication" class="blue"><i class="ace-icon fa fa-search-plus bigger-130"></i></a> <a class="red"><i class="ace-icon fa fa-trash-o bigger-130"></i></a>';
},
"targets": [0],
"data": "",
"mRender": function ( data, type, full ) {
return '<a data-toggle="modal" data-target="#infoModal" id="getPublication" class="blue"><i class="ace-icon fa fa-search-plus bigger-130"></i></a> <a class="red"><i class="ace-icon fa fa-trash-o bigger-130"></i></a>';
}
} ],
"sScrollX": "100%",
"sScrollXInner": "103%",
});
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You mean 5.
Yes, you need to keep in mind that the column indexes are zero based. If you actually want a 7th column in the table, that would also need to be in your columns array.
Also, I would suggest you combine the objects into a single one. You are defining information for column index 0 three times for example. Just do it in a single object and it might be easier to follow.
Allan
No @tangerine. I meant 6. Why I would have meant 5?
For the reason I stated - you have 6 elements in your
columns
array. But yourtargets
option adds one more column. One which doesn't exist in the columns array.Allan