[英]Display to table fetched JSON values in a different format
I currently have a table which displays data like so: 我目前有一个显示数据的表格,如下所示:
http://snag.gy/fyO48.jpg http://snag.gy/fyO48.jpg
I have a service which fetches the data from an SQL server and encodes it into a json. 我有一个从SQL Server提取数据并将其编码为json的服务。 My problem is the json is structured like so:
我的问题是json的结构如下:
http://snag.gy/TqZly.jpg http://snag.gy/TqZly.jpg
count_reqs should be put in the corresponding column. 应将count_reqs放在相应的列中。 For example, the first row data should be displayed as such:
例如,第一行数据应显示为:
http://snag.gy/tB0ji.jpg <--- cant post more links sorry
How can this be done? 如何才能做到这一点?
Here's my code for the table: 这是我的表格代码:
<table class='table'>
<thead>
<tr>
<th>Tower</th>
<th>Job Level</th>
<th ng-repeat='data in dataset.headers'>{{ data }}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat='tower in dataset.dataByTower' ng-init='current = 0'>
<td rowspan='{{ tower.entries.length }}'>{{ tower.tower_name }}</td>
<td>{{ tower.job_level }}</td>
</tr>
</tbody>
</table>
Try this 尝试这个
<table class='table'>
<thead>
<tr>
<th>Tower</th>
<th>Job Level</th>
<th ng-repeat='data in dataset.headers'>{{ data }}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat='tower in dataset.dataByTower' ng-init='current = 0'>
<td rowspan='{{ tower.entries.length }}'>{{ tower.tower_name }}</td>
<td>{{ tower.job_level }}</td>
<td ng-repeat='data in dataset.headers'><span ng-if="data ==tower.year_month">{{ tower.count_reqs}}</span></td>
</tr>
</tbody>
</table>
PS I'm not tested this, because you don't provide jsFiddle or data of your dataset.headers
and dataset.dataByTower
. PS我没有经过测试,因为您没有提供jsFiddle或
dataset.headers
和dataset.dataByTower
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.