【发布时间】:2016-02-22 09:08:56
【问题描述】:
我希望能够在引导表中显示相应行的索引。我的表格如下所示:
<div class="Explorer" style="display:none">
<table class='table'>
<thead>
<tr>
<th>Rank</th>
<th>Username</th>
<th>Points</th>
</tr>
</thead>
{% for instance in leaderboardDictionaries %}
{% for category, userDictionary in instance.items %}
{% if category == "Explorer" %}
<tr><td> {{category}} </td></tr>
{% for name, points in userDictionary.items %}
<tr>
<td data-formatter="runningFormatter" data-field="index">HERE I WANT THE INDEX OF THE ROW?!</td>
<td>{{name}}</td>
<td>{{points}}</td>
</tr>
{% endfor %}
{% endif %}
{% endfor %}
{% endfor %}
</table>
</div>
我在网上查看并找到了这个,但我无法让它以任何有用的方式工作......所以建议是制作一个外部函数:
<script>
function runningFormatter(value, row, index) {
return index+1;
}
</script>
但是我应该如何使用它?该函数已经将行和索引作为参数。而且我想知道为什么表格没有“格式选项”,这样我就默认显示行索引 --- 还是有?
【问题讨论】:
标签: html bootstrap-table