Adding rows to datatable from json object data
Adding rows to datatable from json object data

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Error messages shown: Active:982 Uncaught ReferenceError: device is not defined
Description of problem: I'm using row.add to adding row in my datatable but it gives me an error.
My code:
Not sure specifically where that error is coming from but
row.add()
expects only one row so it shouldn't be placed in an array. You can either remove it from the array or userows.add()
(with ans
) to add multiple rows from an array.If this doesn't help then please post a link to your page or a test case so we can look at what your script is doing.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Ok thanks. I'm now using rows.add(). It seems like working. however it returns: Requested unknown parameter "Res_time". It exists in the json object and have this value: "23-11-19 16:30:35". the same format initialized in the datatable
Minimally post your Datatables init code, the JSON response from the browser's network inspector (steps in this technote). Better would be a link to your page or a test case replicating the issue so we can take a look? Without seeing it we will not be able to help debug. You can build a test case with an example of your JSON response as a Javascript variable.
Kevin
Sorry, you right.
This is the test case
http://live.datatables.net/yowakike/1/edit
When using objects you need to define
columns.data
. Please see the Data Docs for more details.Kevin
Columns data are defined in my original datatable. I tried this sample code:
In response I passed only the data defined in columns.data.
no error, no raw added!!!
Unsing jquery append method the rows was added. But I don't want use jquery because datatable doesn't reorder the rows added in this way.
Please update the test case with this and hopefully you can recreate the problem you are having.
This is true. Although you can use
row().invalidate()
if you go this route.Kevin
OK thanks. I solved it using the rows.add () API. I wasn't using the for loop correctly in the Laravel method and client-side javascript. Thanks again for the support.