My observableArray
is dynamically populated with SQL data, resulting in varying columns each time.
I am trying to present the SQL results in an HTML table but facing issues with the code below.
This is the desired output format...
https://i.sstatic.net/dc7rE.png
var viewModel = function(data) {
var self = this;
// variables
self.taskRecordOverview = ko.observableArray([
{
"Entity": "DEMO",
"Period": "2017-07-31T00:00:00",
"Level": "Level 3",
"Addendum Errors": null,
"Cash Process": "Created",
"Corporate Actions": null,
"Expenses": null
},
{
"Entity": "DEMO",
"Period": "2017-07-31T00:00:00",
"Level": "Level 5",
"Addendum Errors": "Created",
"Cash Process": "Created",
"Corporate Actions": "Created",
"Expenses": "Created"
},
{
"Entity": "SP00",
"Period": "2017-07-31T00:00:00",
"Level": "Level 5",
"Addendum Errors": "Created",
"Cash Process": "Approved",
"Corporate Actions": "Created",
"Expenses": "Created"
}
]);
};
ko.applyBindings(new viewModel());
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
<table>
<thead>
<tr>
<th>??</th>
</tr>
</thead>
<tbody data-bind="foreach: taskRecordOverview">
<tr>
<td data-bind="text: $data"></td>
</tr>
</tbody>
</table>