I'm working on a project that requires a table to be dynamically constructed from an array of header objects:
[{ field: "name", show: true, title: "Name"},
{ field: "id", show: true, title: "ID"},
{ field: "time", show: true, title: "Time"}]
and an array of data objects that is updated at an interval:
[{ name: "Abc", id: 123, time: "300" },
{ name: "Def", id: 456, time: "10" }]
My template looks something like this:
<table class="table">
<thead>
<th ng-repeat="header in cols">
{{::header.title}}
</th>
</thead>
<tbody>
<tr ng-repeat="row in visibleData">
<td ng-repeat="col in cols">
{{::row[col.field]}}
</td>
</tr>
</tbody>
</table>
Please note that this is a simplified version but it holds the important bits.
As of now, rendering a table with 10 cols and 20 rows takes around 200ms (which creates a noticeable lag in scrolling and other page animations).
As you can see, I've tried to use one-time biding but that hasn't improved the performance noticeably. Another thing I've tried was to 'track by' row.id, but this caused the data to stop updating altogether (The initial DOM object is reused even though some columns have changed).
So my question is, what measures should I take in order to optimize this configuration?
Any help would be greatly appreciated. Thanks :)