Build array of objects with specific column data
Build array of objects with specific column data

Greetings. Variable below is required to build an array of objects with data from columns 1 and 6. With configuration below, a single array is built. Kindly assist.
var allData = this.api().cells(this.api().rows, [ 1,6 ]).data().toArray();
Output for above is ["ABCD", 1, "EFGH", 2, "IJKL",3]
Desired output is [{"ABCD", 1}, {"EFGH", 2}, {"IJKL",3}]
This discussion has been closed.
Answers
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Hi Colin,
Sorry about that. Test case available at http://live.datatables.net/nawudoba/8/edit
Require to see the following array of objects in the console
[
{"Airi Satou", "Accountant"},
{"Ashton Cox", "Junior Technical Author"},
{"Cedric Kelly", "Senior Javascript Developer"},
{"Tiger Nixon", "System Architect"},
{"Tiger Nixon", "Accountant"}
]
Just use
rows().data()
, like this:http://live.datatables.net/nawudoba/11/edit
Kevin
Thankyou for the answer Kevin. However, Im looking to export values of columns 0 and 1 not rows 0 and 1.
You can use
columns().data()
for that, so something likecolumns([0,1]).data().toArray()
Colin