Lattice Grid Buy a licence

demo D197

Running totals

The one derived value that depends on the display order

running: { of, kind: 'total' }

Building…
Loading a live grid…

The configuration

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/lattice-grid.min.css">

<script type="module">
  import { defineLatticeGrid } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/modules/webcomponent.esm.js';
  defineLatticeGrid();
</script>

<lattice-grid row-key="id" style="display: block; height: 540px"></lattice-grid>

<script type="module">
  const grid = document.querySelector('lattice-grid');
  grid.config = {
    columns: [
      { field: 'date', title: 'Date', type: 'dateString', layout: { pin: 'start', width: 150 } },
      { field: 'amount', title: 'Amount', type: 'number', format: { style: 'currency', currency: 'USD' }, total: 'sum' },
      // A running total depends on the display order, so it is running, not
      // shadow: sort the grid and every running value changes.
      { id: 'cum', title: 'Running', type: 'number', format: { style: 'currency', currency: 'USD' }, running: { of: 'amount', kind: 'total' } },
      { id: 'share', title: 'Cumulative %', type: 'number', format: { style: 'percent', decimals: 1 }, running: { of: 'amount', kind: 'percent' } },
    ],
    state: { sort: [{ col: 'date', dir: 'asc' }] },
  };
  grid.rows = rows;  // e.g. [{ id: 1, date: '2026-01-01', amount: 520.4 }, ...]
</script>