Can toArray() be used on .row().data()?
Can toArray() be used on .row().data()?

In my project, I want to get a row of data from the table as an array. In the table, it is an object. I see that there is a .toArray() function and that the example is used on .column(0).data(), but when I try the following, I get an error:
currentData[j] = table.row('#'+changes[i][0]).data().toArray();
This results in "Uncaught TypeError: table.row(...).data(...).toArray is not a function". Am I doing something wrong, or can toArray() not be used on a row?
(note: changes[i][0] contains the row id of the row I want to get)
This question has an accepted answers - jump to answer
Answers
Using
row().data()
returns the row as an object or array depending on what the Datatable was populated with. ThetoArray()
API is used with API's that return API objects likerows().api()
. It will take the API object and return a Javascript array of the row data (either an array of objects or an array of arrays depending on what populated the Datatable.toArray()
won't convert object based data to an array. You will need to code this yourself or use something like Object.values().Kevin
Ah. Thanks. I misread the row().data() page and though it also returned an API for some reason. Maybe I was accidentally looking at rows().data().
Anyway, I already have a solution with a $.map, but I was wondering if I could simplify it. Apparently not that way. Thanks again.