【发布时间】:2014-05-01 17:53:46
【问题描述】:
如何使用 Twig 找到列中所有行的总值?例如,我有一列“QTY”,它将列出每行的数量,我想要 QTY 的总 ROWS 的总和(而不是数量的总和)。 Twig 中的标签/逻辑是什么?
我有这样的事情:
<table class="tablesorter">
<thead>
<th>DA</th>
<th>Part</th>
<th>Batch</th>
<th>Qty</th>
</thead>
{% for getbatches in getbatch %}
<tr>
<td>{{getbatch.dano}}</td>
<td>{{getbatch.partno}}</td>
<td class="highlight">{{getbatch.batchno}}</td>
<td>{{getbatch.inqty}}</td>
</tr>
{% endfor %}
</table>
对于填充的行,我想要 QTY 列或任何列的计数。
【问题讨论】:
-
这真的是 Twig 的工作吗?
-
“QTY 的总 ROWS 之和”是什么意思?您是指 QTY 列中的行数吗?您是指 QTY 列每行内的值的总和吗?
-
@Javad QTY 列的行数。
-
你能把你如何在twig中创建表格的代码放上去吗?这将有助于解决您的问题