aoColumnDefs + columnDefs
aoColumnDefs + columnDefs

Hi,
i have this code which works great // hide column but filter enable
"aoColumnDefs": [{ "bSearchable": true, "bVisible": false, "aTargets": [ 10 ] },]
but if I go to insert this too the code above doesn't work
"columnDefs": [ //
{
"targets": 3,
"render": function (data, type, row, meta) {
if (type === 'display') {
var label = 'label-success';
if (data > 30 && data < 60) {
label = 'label-warning';
} else if (data > 60) {
label = 'label-danger';
}
return '<span class="label ' + label + '">' + data + '</span>';
}
return data;
}
}
]
in this way
"aoColumnDefs": [{ "bSearchable": true, "bVisible": false, "aTargets": [ 10 ] },]
"columnDefs": [ //
{
"targets": 3,
"render": function (data, type, row, meta) {
if (type === 'display') {
var label = 'label-success';
if (data > 30 && data < 60) {
label = 'label-warning';
} else if (data > 60) {
label = 'label-danger';
}
return '<span class="label ' + label + '">' + data + '</span>';
}
return data;
}
}
]
This question has accepted answers - jump to:
This discussion has been closed.
Answers
They are both the same option. The
aoColumnDefs
is the legacy form of the option from Datatables 1.9. ThecolumnDefs
is the current form. See this Conversion Guide for more details.One option is overwriting the other. Combine them into one
columnDefs
option. Its suggested that you use the current instead of the legacy form of the options.Kevin
Hi kthorngren
sorry, but I'm not a programmer,
just hobbies, I'm trying to learn,
explain me how to fix my code
This is what you want:
Kevin
i find solution
https://datatables.net/forums/discussion/50691/how-to-use-columndefs-multiple-time-in-a-datatable
Thank you kthorngren