JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://knockoutjs.com/downloads/knockout-2.2.1.debug.js"></script>
<table>
<thead>
<tr data-bind="foreach: columnNames">
<th> <span data-bind="text: $data"></span>
</th>
</tr>
</thead>
<tbody data-bind="foreach: items">
<tr data-bind="foreach: $parent.columnNames">
<!-- how do I put the Value property here? -->
</tr>
</tbody>
</table>
JavaScript
var VM = function () {
var self = this;
self.items = ko.observableArray();
self.columnNames = [ "Name", "Age", "Job"];
};
var vm = new VM();
ko.applyBindings(vm);
vm.items.push(
{
'ColumnName': 'Name',
'Value': 'John'
},
{
'ColumnName': 'Age',
'Value': 25'
}
);
vm.items.push(
{
'ColumnName': 'Name',
'Value': 'Jane'
},
{
'ColumnName': 'Age',
'Value': 26
},
{
'ColumnName': 'Job',
'Value': 'developer'
}
);