Closed brendon closed 6 years ago
You can build one yourself with:
%table
= datagrid_header @grid
= datagrid_rows @grid
%tr.total-row
%td{rowspan: x} Total
%td= @grid.total_sum
There is no built-in support so far because there is no good API that would support all the cases...
Ah righty! That's a very decent workaround! Thanks for that :D
%table = datagrid_header @grid = datagrid_rows @grid %tr.total-row %td{rowspan: x} Total %td= @grid.total_sum
Hey ! Sorry I'm a total rookie. I don't understand where I should write these lines and where does total_sum come from ?
Write those lines the template. If you are rookie, use ERB:
<table>
<%= datagrid_header @grid %>
<%= datagrid_rows @grid %>
<tr class="total-row">
<td rowspan="<%= x %>">Total</td>
<td>
<%= @grid.total_sum %>
</td>
</tr>
</table>
Define total_sum
as a method on a grid:
class MyGrid
...
def total_sum
end
end
I was wondering if there's any capability or workarounds in
datagrid
for an aggregate row at the bottom of the table? For example, totalling the price in a column of each row on the last row. :)