Adding dynamically rows to a datable
Adding dynamically rows to a datable
Dear Datables community,
I need help. I cannot find a solution to my problem after having read the documentation several times. I have a dynamic array manipulated by a field. An Ajax request is used to retrieve a json.
You will find below the shape of the object:
data = [{"name1":"ref2","name2":"55xXXXX","dates":{"date1":"2019/11/19 00:00:00"}},{"name1":"ref2","name2":"XXXX555","dates":{"date1":"2020/03/20 00:00:00"}}]
My table is already declared in my html. With my js file I would like to add or delete lines.
I always get the same error. I tried via initialize function of datatables and also via rows.add.
$("#table1").DataTable({data: data,colums: [{data: 'name1'},{data: 'name2'},{data: 'dates.date1'}]})
table.rows.add(data).draw()
Thanks, have a great day
Answers
You misspelled columns.
Kevin
It was a mistake. My problem is that after a clear () or a delete(), it is impossible to insert data.
Please post a link to your page or a test case replicating the issue. We need to see what is happening in order to offer suggestions.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Do you get errors in the browser's console?
Kevin
The issue that i have : "DataTables warning: table id=tableAffaires - Requested unknown parameter 'T0' for row 6, column 2. For more information about this error, please see http://datatables.net/tn/4"
No error in browser's console.
Have you followed the diagnostic steps explained in the link?