**Hi sorry something went wrong i posted this question 2 times, the other one can be deleted maybe? **
Hi Guys,
I really like all the options DataTables offer, but i have an problem:
The following works: (loads my datatable with json which contains table header names + data for in tbody):
$.ajax({
"url": 'java/medewerkers.json',
"dataType": 'json',
"success": function (json) {
var table = $('#customersTbl').DataTable(json);
}
});
});
// json:
{
"columns": [
{
"title": "Firstname",
"data": "employee_name"
},
],
"data": [
{
"id": "cb0_1034400",
"employee_name": "Ha",
"employee_firstnames": "Har",
"employee_surname": "Bos",
"employee_gender": "m",
"employee_mobile": "06 53",
"employee_emailaddress": "h@g.com"
}
]
}
But when i want to add this to my live project which contains alot of parameters and settings in the datatable like so:
function toDataTable(json) {
var table = $('#customersTbl').DataTable({
data: json,
buttons: [
{
extend: 'colvis',
text: '<i class="fa fa-wrench"></i>',
init: function (api, node, config) {
$(node).removeClass('btn-secondary')
$(node).addClass('btn-outline-secondary')
}...
or something like:
var table = $('#customersTbl').DataTable({
"ajax": {
"url": "path/path.json",
dataSrc:'tried every way mentioned on the website.'
},
buttons: [
{
extend: 'colvis',
text: '<i class="fa fa-wrench"></i>',
init: function (api, node, config) {
$(node).removeClass('btn-secondary')
$(node).addClass('btn-outline-secondary')
}....
It just doesn't work, tried everything i could find or come up with.. I only get the following error:
VM817 jquery.dataTables.min.js:66 Uncaught TypeError: Cannot read property 'aDataSort' of undefined.
I tried every suggestion on the website. Put the ajax function in the datatable func.
With or without on succes. with type: json etc etc tried everything.
Any suggestion guys?