using javascript arrays for aaData

using javascript arrays for aaData

pedalshoepedalshoe Posts: 9Questions: 0Answers: 0
edited October 2011 in DataTables 1.8
Hi,
i have a 2d javascript array defined as:
var myData = new Array(1)
myData [0] = new Array();

and I insert data into the array:
var i=0;
myData[0][i++] = "myData1";
myData[0][i++] ="myData2";
...

when i initialize my single column dataTable using:
"aaData":myData,..

the data table only shows one row of data. (the first record only)

Is there something I'm doing wrong here?

Thank you,
Christopher

Replies

  • pedalshoepedalshoe Posts: 9Questions: 0Answers: 0
    This link helped me understand what was missing..
    http://www.datatables.net/release-datatables/extras/Scroller/large_js_source.html

    Instead of trying to make a 2d array, i just inserted the new row by using push(["myDataN"]);
    using the square brackets to specify an array (although it is only one element).

    -Christopher
  • Mango_DeliciousMango_Delicious Posts: 1Questions: 0Answers: 0
    This was my problem too! After an hour I found this page, made my morning, thanks.

    Here's my sample code too, just for anyone else in the future:

    // Processing JSON data into an array
    for (i=0; i
  • dj_mckingdj_mcking Posts: 1Questions: 0Answers: 0
    thanks Mango_Delicious i came across this just in time. :) and works like a charm.
  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    There is an example showing how to do this here: http://datatables.net/release-datatables/examples/data_sources/js_array.html . You want want to also consider enabling deferred rendering ( bDeferRender ) for a bit more speed :-)

    Allan
This discussion has been closed.