1

I want to populate data table with dynamic column header and column data, I can populate dynamic column data successfully, but I can't achieve dynamic column...

I am using JSON array.

My html code is:

 <body>
    <table id="example" class="display" cellspacing="0" width="100%" border="1">
    </table>
 </body>

My JavaScript code is.

  <script>
  var JSONResult = '{
     "column1":"data1",
     "column2":"data2",
     "column3":"data3",
     "columnN":"dataN"}';
  var row_dtable = new Array();
  var dtable_api = $('#example').dataTable();
  $.each(JSONResult , function(key, value) {
         row_dtable.push(value);
       }); 
  dtable_api.api().row.add( row_dtable ).draw( false );   
  </script>
  • How this is GIS related? – Jonatas Walker Jun 17 '16 at 16:18
  • I am developing this application in ol3, resultant column will get from geojson file. – Priyanka Jun 20 '16 at 4:19
  • what errors or issues do you get? – nmtoken Oct 7 '16 at 17:10
1

this is a little late but i think you are missing some tags. change this :

<table id="example" class="display" cellspacing="0" width="100%" border="1">
</table>

to this :

<table id="example" class="display" cellspacing="0" width="100%" border="1">
   <thead></thead>
   <tbody></tbody>
</table>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.