Sum of values

40 views
Skip to first unread message

Rafael Estevao

unread,
Jun 19, 2017, 12:00:21 PM6/19/17
to KnockoutJS
Hi guys,

I have values (Valor1+Valor2+Valor3) in my table. 

in header, i have sum values, it is correctly "sum(Valor1+Valor2+Valor3)"?


<table class="table table-bordered table-responsive">
<tr>
<th>Total</th>
<th data-bind="value: sum(Valor1+Valor2+Valor3)"></th>
</tr>
</table>


<table id="tblExport" class="table table-bordered table-responsive">
<thead>
<tr>
<th class="text-left">Data</th>
<th class="text-center">Fichas Públicas Disponíveis</th>
<th class="text-center">Máximo de Fichas por Médico</th>
<th class="text-center">Disponíveis</th>
<th class="text-center">Compartilhadas</th>
</tr>
</thead>
<tbody data-bind="foreach: listaDepositosAtivos">
<tr>
<td class="text-center" data-bind="text: Valor1"></td>
<td class="text-center" data-bind="text: Valor2"></td>
<td class="text-center" data-bind="text: Valor3"></td>
</tr>
</tbody>
</table>

Phạm Dũng

unread,
Jun 20, 2017, 3:52:45 AM6/20/17
to KnockoutJS

When you push into listaDepositosAtivos 

you can use total = ko.compute(function(){
                                    return val1+val2+val3;
                             })


Vào 23:00:21 UTC+7 Thứ Hai, ngày 19 tháng 6 năm 2017, Rafael Estevao đã viết:
Reply all
Reply to author
Forward
0 new messages