Populating Datatable using Javascript array

Populating Datatable using Javascript array

premkumar.dnbpremkumar.dnb Posts: 1Questions: 0Answers: 0
edited June 2011 in General
I am new to this forum and datatable, i am tring to use datatable for displaying data in UI. I i am getting from a dataset converting them into JSON and populating data in javascript array to display data in Datatable. I shall have dynamic column. Below i have given my code. I dont find any problem in filling up the array, but rendering it to datatables is not working.

CLIENT CODE
-----------------
var xml = document.getElementById("hdn").value
var json = $.xml2json(xml);

var strcolumnheader;
strcolumnheader = "<%=strcolumnheader %>"
strcolumnheader = strcolumnheader.split(",");

var columnname = "";
var tblData ="";
var rowdata = "";
var jsarray = new Array();
for (i=0;i

Replies

  • southof40southof40 Posts: 4Questions: 0Answers: 0
    edited June 2011
    I've only just started using DataTables myself but there are two things that occur to me:

    First I don't think the value for "aaData" should have square brackets wrapped around it, that is I think it should be :

    "aaData": jsarray

    Secondly I think jsarray should be an array of arrays and I'm not sure it is currently.

    I'm doing something very similar to you at the moment and my data looks like this :

    jsarray = [[1,2,3],[10,20,30],[100,200,300]];

    I think in your code rowdata should be initialized as an array instead of a string. Something like this :

    for (i=0;i
  • southof40southof40 Posts: 4Questions: 0Answers: 0
    edited June 2011
    [I've noticed you can edit these comments so I've edited the original comment as well as put this out there]

    Correction to my previous comment:

    First I don't think the value for "aaData" should have square brackets wrapped around it, that is I think it should be :

    "aaData": jsarray
This discussion has been closed.