Fill Data Table with json Data from Ajax Call
Fill Data Table with json Data from Ajax Call
Hi All,
I have gone through some of the examples of loading a data table from json and ajax call. However I have not found any that answers my question. I have a table that I dynamically create using Javascript. The table is filled when I make an Ajax call to a webservice.
My questions are as follows: I want to fill data table with some of these data not all, but the examples I have found so far will just take all the data and present them in the data table, So how can I specify only the fields I need to be shown on data table.
Also my table header are also shown from javascript, this is because i don't want the table shown until it is needed.How can I include this in data table dynamically. I have posted in JsFiddle http://jsfiddle.net/aadewojo/Lk8px/1/ the javascript that I use to fill the traditional html table from my webservice.
Thanks and looking forward to your reply.
This question has an accepted answers - jump to answer
Answers
I have some code that loads JSON data through ajax, transforms them into the
aaData
-style array and then loads into the dataTable. It is not a tutorial example (I'm also new to dataTables) but it is a code that works.https://github.com/xmojmr/component.io/blob/0.1.0/js/main.js#L7 starts transforming the json into the aaData format.
https://github.com/xmojmr/component.io/blob/0.1.0/js/main.js#L113 has the aaData ready and creates the dataTable.
(latest version of the code is available at http://xmojmr.github.io/component.io/, the above links point to an older version with fixed line numbers. The data loading concept is still the same)
Thanks for the reply. I got it working now.