I need multiplication of two values data inside table html jsreport
qty * valor --> calculate inside table row by row Everything it's ok, just need calculation
<div class="items">
<!-- DIV DA TABELA DE ITEMS -->
<div></div>
<table class="table-items">
<thead>
<tr class="tr-items">
{{props items}} {{if key
<=0 }} {{props prop}} <th class="th-items">{{>key}}</th>
{{/props}} {{/if}} {{/props}}
<th class="th-items">Total</th>
</tr>
</thead>
<tbody>
{{for items}}
<tr class="tr-items">
<td class="td-items">
{{>date}}
</td>
<td class="td-items">
{{>qty}}
</td>
<td class="td-items">
{{>item}}
</td>
<td class="td-items">
{{>valor}}
</td>
<!-- <td> {{total items}}{{/total}}</td> -->
<td class="td-items">
{{>qty}} * {{>valor}} €
</td>
</tr>
{{/for}}
</tbody>
</table>
</div>
To performa a calculation in jsrender, surround the calculation with parentheses:
<td class="td-items">
{{>(qty * valor)}} €
</td>
Breaking News
It turns out that the "valor" property is a string of the form "50.00 EUR", so the number portion of the string needs to be extracted. This revised form will do the trick:
{{>(qty * valor.split(' ')[0])}}
It also turns out that the parentheses are optional, so this also works:
{{> qty * valor.split(' ')[0]}}