Kenny Shaw Kenny Shaw - 3 months ago 6
Javascript Question

Use datatables.net with javascript

So I have a few javascript arrays, ex.

array1 = [1,2,3]
and
array2 = [4,5,6]
and I want these arrays to represent the column data, not row data like it wants.
How would I make the table to look like:

This

I've been pulling my hair out all day, and I can't seem to find a solution......is this even supported?

Answer

Simply output the data how you need it.

var rows = '';

for (var i = 0; i < array.length; i++) { //assumes equal size arrays
  rows += '<tr><td>'+array[i]+'</td><td>'+array2[i]+'</td></tr>';
  //or however you do this
}
Comments