I am using dynatable.js to print my json data in table format.When i hard code the with names as jdbc_driver_id and database_id the json data is printed correctly.But the json data received each time is different with different names.I want different names inside tag depending upon the data received from json.Please tell me a solution for my query.
/***************************JS FILE********************************/
$(function(){
//HERE I AM GETTING MY JSON RESPONSE AS KEY AND VALUE.I WANT THE NAME INSIDE <TH> DYNAMICALLY SINCE MY JSON DATA RECEIVED IS DIFFERENT EACH TIME.//
json response is
[{"database_id":"1","jdbc_driver_id":"2"},
{"database_id":"2","jdbc_driver_id":"1"},
{"database_id":"3","jdbc_driver_id":"4"},
{"database_id":"4","jdbc_driver_id":"1"}]
//SO IN THE response I AM GETTING THE ABOVE JSON DATA//
var response = jQuery.parseJSON(response);
var dynatable =$('#my-final-table').dynatable({
table: {
defaultColumnIdStyle: 'underscore'
},
dataset: {
records: response//HERE IS THE JSON RESPONSE//
}
});
});
/************************JSP PAGE********************************/
//I WANT DYNAMIC NAMES INSIDE THE TH TAG//
<table id="my-final-table">
<thead>
<th>jdbc_driver_id</th>
<th>database_id</th>
</thead>
<tbody>
</tbody>
</table>