demo D197
Running totals
The one derived value that depends on the display order
running: { of, kind: 'total' }
Loading a live grid…
The configuration
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.13.0/lattice-grid.min.css">
<script src="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.13.0/lattice-grid.min.js"></script>
<div id="grid" style="height: 460px"></div>
<script>
const grid = LatticeGrid.createGrid(document.getElementById('grid'), {
rowKey: 'id',
columns: [
{ field: 'date', title: 'Date', type: 'date', layout: { pin: 'start', width: 150 } },
{ field: 'amount', title: 'Amount', type: 'number', total: 'sum' },
// A running total depends on the display order, so it is running, not shadow.
{ id: 'cum', title: 'Running', running: { of: 'amount', kind: 'total' }, type: 'number' },
{ id: 'share', title: 'Cumulative %', running: { of: 'amount', kind: 'percent' }, type: 'number', format: { style: 'percent' } },
],
state: { sort: [{ col: 'date', dir: 'asc' }] },
rows,
});
</script>