fnAddData

fnAddData

tyroneschifftyroneschiff Posts: 5Questions: 0Answers: 0
edited May 2011 in General
I would like to iterate over a json array and add data from it to my DataTable using fnAddData from the API. My json data is takes the form of:
[code]
{
-1: [
-{
number: 1
value: "100"
name: "Jones"
address: "100 S. Street"
country: "USA"
}
]
}
[/code]

I'm having a hard time understanding how I can iterate over this json array and use the fnAddData to update my table. Would someone please assist me with the implementation?

Replies

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    Two options - you can use the new data source options in 1.8: http://datatables.net/blog/Extended_data_source_options_with_DataTables - or you can simply construct a 1D array from each object and pass that to fnAddData (e.g. [ a[i].number, a[i].value ... ]).

    Allan
This discussion has been closed.