How could I get columns structure automatically with this kind of datatable? The idea is that there will be different number and order of columns depending of the params that I send to the server using the ajax data source with objects.
(I only need the base names of the columns, I don't need the translated ones)
here is my code simplified:
var tableId = 'tableId';
var tableName = jQuery('#' + tableId).DataTable({
language: dataTablesTexts,
pagingType: 'full',
lengthMenu: [
[5, 10, 25, 50, -1],
[5, 10, 25, 50, 'All'],
],
searching: true,
ordering: true,
aaSorting: [],
paging: true,
select: false,
info: true,
responsive: true,
ajax: {
type: 'POST',
url: '/historic/getTasks',
data: function (d) {
return $.extend( {}, d, {
token: localStorage.token,
params: params
});
},
dataSrc: ""
},
columns: [{
data: 'name',
title: lang.name
}, {
data: 'description',
title: lang.description
}, {
data: 'edit',
title: ''
}]
});