Background:
I'm busy building a application which (amongst other things) has to be able to show a report. I choose DataTables because it works awesomely and it was easy to implement. I've made an application which is based on one (static) dataset. However, I have gotten the request to alter the application to be able to work with multiple datasets.
Question:
Amonst other things, i want to replace the statically defined columns (see code snippet), with a variable. In this case an array with id, keten, name, x, y, which will be declared somewhere else dynamically.
How do i change my function to incorporate a variable array instead of hardcoding the columns?
The end result should change from
"columns": [
{"data": "id"},
{"data": "keten"},
.......
to something like
"columns": [
{"data": *variableReportData*}
Code:
function rapport_vullen(){
$("#rapport").dataTable({
destroy: true,
"aaData": geojson.features.map(function(row) { return row.properties; }),
"columns": [
{"data": "id"},
{"data": "keten"},
{"data": "name"},
{"data": "x"},
{"data": "y"}
]
});
download_rapport()
};