the foreach should be a parent element, since that is not possible in your case you should use the comment notation: http://jsbin.com/wideyeku/2/edit?html,js,output
<thead>
<tr>
<th>Name</th>
<!-- ko foreach: assignments -->
<th><input data-bind="value: workName"/></th>
<!-- /ko -->
</tr>
</thead>
UPDATE: http://jsbin.com/wideyeku/4/edit?js,console,output I found out you had some logical mistakes in your code:
first of all, this
is variable in javascript, so keep a reference to it in your model:
function StudentsViewModel() {
var self = this;
then correct your update rows function:
this.updateRows = function () {
ko.utils.arrayForEach(this.students(), function(student){
while(student.scores().length < self.assignments().length){
student.scores.push("");
}
})
};
never forget that observableArrays are functions, and need to be invoked.