Im trying to render a table in knockout. The code works but as the number of rows and columns grow the rendering times become extremely long. The culprit seems to be notifying subscribers and actually performing the bindings. I'm wondering if there is a way that the table could be rendered in a way that didn't cause knockout to do so many events. This table literally has no interaction. It is purely just to display data. I was hoping to accomplish this without the need to bring in another templating engine and just use what Knockout.js has available with the data-bind attributes but I've tried and nothing seems to be satisfactory. I have two observable arrays, one for headers and one for the data. the data array is an array of arrays because I have to build out each row seperately.
<table>
<thead>
<tr>
<!--ko foreach: headers -->
<th data-bind="{'text': displayName}"></th>
<!-- /ko -->
</tr>
</thead>
<tbody data-bind="foreach: row">
<tr class="form_row">
<!-- ko foreach: question -->
<!-- ko if: Type === "image" -->
<td>
<a data-bind="attr: {'href': $data.Value, 'target': '_blank'}">
<img class="thumbnail-img" data-bind=" attr: {'src': $data.Value}" />
</a>
</td>
<!-- /ko -->
<!-- ko if: Type !== "image" -->
<td data-bind="{'text': Value}"></td>
<!-- /ko -->
<!-- /ko -->
</tr>
</tbody>
</table>
You can use this JsFiddle to run something similar to my example. http://jsfiddle.net/LkqTU/27820/