Datatable not showing entries with ajax object
Datatable not showing entries with ajax object
dvdhoek
Posts: 5Questions: 2Answers: 0
I'm trying to rewrite some stuff but can't get the table to display the values;
http://debug.datatables.net/adufar
The JSON response looks ok to me, but perhaps something is wrong.
table = $('#example').DataTable( {
serverside: false,
ajax: {
url: "sales/data",
type: "GET"
},
columns: {
data: 'user_id2',
data: 'first_name',
data: 'last_name'
},
createdRow: function ( row, data, dataIndex ) {
$(row).attr('id', data[0]);
},
order: [ 5, 'desc' ],
columnDefs: [ {
"targets": 11,
"data": null,
"defaultContent": "<button id='create-ticket'>Ticket</button>"
},
{
"targets": 12,
"data": null,
"defaultContent": "<button id='family-details'>Details</button>"
}],
bSortClasses: false,
pageLength: 50,
buttons: [
'csv'
],
fnInitComplete: function() {
$('.loader').hide();
$('#data-table').show();
}
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I'm no expert here, but why do you use type: GET? I think da datatables expect POST?
columns
has to be an array of objects. At the moment you just have a single object.It also needs to be exactly the same length as the number of columns in the table. Based on the
columnDefs
array that is at least 13 columns.Allan
Thanks, stupid mistake.