Is it possible to override columns (and values set in settings) in js that can be passed through an ajax call?
I know that thanks fnReloadAjax
or combination fnClearTable()
and fnAddData()
I can reload some fresh data
but is it possible in this way to override the table settings, in particular: the names of the columns that are hidden, which are visible?
UPDATE : If you decide to destroy the table, the easiest way is to check for existence and destroy that:
if $.fn.DataTable.isDataTable("#element") {
$('#element').DataTable().destroy();
}
maybe just by setting a property in the DataTable definition :bDestroy: true
source to share
I think you can change the settings by destroying the dataTable altogether like:
//part1
$( "#element" ).dataTable({
"sPaginationType": "full_numbers",
"iDisplayLength": 25,
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 0 ] } //cannot sort using column 1
]
});
----------
//part2
$( "#element" ).dataTable().fnDestroy();
$('#element').dataTable( {
"aoColumnDefs": [
{ "bVisible": false, "aTargets": [2] } //hiding the column 3
]
} );
Here I just destroyed the dataTable for no reason, but you can bind it to some event.
source to share