Populating Datatable using Javascript array
Populating Datatable using Javascript array
premkumar.dnb
Posts: 1Questions: 0Answers: 0
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
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
This discussion has been closed.
Replies
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
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