Can I use Datatables with a Javascript Array of Objects?
Can I use Datatables with a Javascript Array of Objects?
Just trying to figure things out and figured you guys might be able to give me a hand.
I am working off of the Javascript Sourced Data page in the examples section, and I am seeing that the arrays are such like:
var Array =[array[]]
The data im using is strickly an Array of Objects such as:
var Array = [object{}]
Unfortunately it seems that the array of objects doesnt work the same way as array of array does. Is anyone able to give me a hand and help me figure out how to make this one work?
Note, I am using Sharepoint Services to get this information, not AJAX or any other sort of information gathering service, thus I do believe the array of objects is all I can get.
Thank you!
Answers
You could map the values to a new array?
Something like:
Then just use that array instead. Won't work on IE8 or older (ES6 required)
Hi @Twitchy ,
Yep, that's all good, see this example here. With objects, you need to define the
columns
, but otherwise all the rest is the same.Hope that helps,
Cheers,
Colin