I've got what I Think is an array of objects like this console.log shows
Array(39) [ {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, … ]
0: Object { Name: "Jason", Grade: 12 }
What code should I use to format it so that the jQuery datatable will let me set this as the source?
I tried to do this, but it gives me an error:
$.myjQuery = function(testData) {
$('#example').DataTable({
data: testData,
columns: [
{ title: 'Name' },
{ title: 'Grade' },
],
});
testDatavariable, as text, and ideally as part of a minimal reproducible example. (The link in the comments is for an array of arrays - which is different from what you have. But you don't need to convert your array of objects into an array of arrays.){ title: 'Name' }in your DataTable definition, whereas you should have used{ data: 'Name' }. See columns.title vs. columns.data.