Using 2D Array
Using 2D Array
Petty_Crim
Posts: 4Questions: 0Answers: 0
I have a 2d associative array that is generated via ajax and I have seen no where in the documentation on how to use it with this script.
Do I have to manually go around ripping out the headers and sticking them into another array called aaColumns and then shove the data into aaData because it seems rather un practical if thats the case.
Do I have to manually go around ripping out the headers and sticking them into another array called aaColumns and then shove the data into aaData because it seems rather un practical if thats the case.
This discussion has been closed.
Replies
Allan
myarray[0]["name"]="Dog"
myarray[0]["type"]="Animal"
myarray[0]["age"]="5"
myarray[1]["name"]="Dell 486"
myarray[1]["type"]="computer"
myarray[1]["age"]="1"
I want to make a table from that but this is generated dynamically via ajax. Is there a way to use that with datatables?
Allan
My code is the following:
var aaData=myarray;
$('#example1').dataTable( {
"aoColumns": [
{ "mDataProp": "vehicle_id" },
{ "mDataProp": "cell2" },
{ "mDataProp": "cell3" }
],
"aaData": aaData});
Allan
"field name": "value". I have converted the json to a 2d array like it said though so its not a json problem.
Allan