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">
<style>
  #grid > div { height: 460px; }
</style>
<div id="grid"></div>

<script type="module">
  import * as Vue from 'https://esm.sh/vue@3';
  import { createGrid } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/lattice-grid.esm.min.js';
  import createLatticeGrid from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/modules/vue.esm.min.js';

  const LatticeGrid = createLatticeGrid({ vue: Vue, createGrid });

  Vue.createApp({
    components: { LatticeGrid },
    data() {
      return {
        config: {
          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,
        },
      };
    },
    template: '<lattice-grid v-bind="config" />',
  }).mount('#grid');
</script>