DataTable won't load new data with row.add()
DataTable won't load new data with row.add()
kreso191
Posts: 5Questions: 5Answers: 0
This is my code that I think is supposed to work, but it doesn't.
I get this error 'DataTables warning: table id=ukupna - Requested unknown parameter '0' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4'.
CODE:
var table = $("#ukupna").DataTable();
table.row.add(
{ "to_char":"06.12.2017",
"do_sati":"14:00",
"pn":"172647",
"otp_naziv":"KONDUR AS SEPT 2017",
"tiraz":"43000",
"kg":"null",
"napomene":"",
"ide_vraca":"",
"kolicina":"43000",
"ceil":"null",
"pakiranje":"400",
"paleta":"1",
"paleta_euro":"0",
"naru\u010ditelj":"ROTOGRAFIKA",
"adresa":"Segedinski put 72",
"ptt":"24000",
"naselje":"Subotica",
"drzava":"SRB",
"pak":"",
"kontakt":"null",
"komercijalista":"Ljiljana \u0110ukanovi\u0107",
"nacin":"Kamionom"})
.draw();
TABLE DEFINITION:
$('#ukupna').DataTable({
"paging": false,
"scrollCollapse": true,
stateSave: false,
"bSort": false,
bInfo: false,
"autoWidth": false,
columnDefs: [
{targets: [4, 5, 8, 9, 11, 12, 13], "sClass": "numericCol"}],
"oLanguage": {"sSearch": "Traži"},
dom: '<"fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix ui-corner-tl ui-corner-tr"lfr B>' +
'lrtip' +
'<"fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix ui-corner-bl ui-corner-br"ip>',
"stripeClasses": ['strip1', 'strip2'],
"columns": [
{"width": "2%"},
{"width": "2%"},
{"width": "2%"},
{"width": "12%"},
{"width": "2%"},
{"width": "2%"},
{"width": "4.7%"},
{"width": "8%"},
{"width": "2%"},
{"width": "2%"},
{"width": "2%"},
{"width": "1%"},
{"width": "1%"},
{"width": "4.7%"},
{"width": "2%"},
{"width": "2%"},
{"width": "2%"},
{"width": "1%"},
{"width": "0.01%",
"visible": false,
"searchable": false
},
{"width": "4.7%"},
{"width": "2%"},
{"width": "4.7%"}
]
});
This discussion has been closed.
Answers
Hi @kreso191 .
The problem is because you're trying to add the row as an object, whereas it's expecting an array - you didn't define the data as an object when initialising the table. See the second example on the
row.add()
reference page.Cheers,
Colin