Lattice Grid Buy a licence

demo D187

Marking a baseline in Svelte

"Mark all" resets every delta to now

grid.statistics.rebase(col)

This grid resets every delta to now with a single 'mark all', setting a fresh baseline. It lets a reader say 'watch from here', so change tracking restarts from the current moment rather than page load.

Building…
Loading a live grid…

This is the Svelte version. A use action attaches the grid to a plain element, so no framework runtime is passed in and the component stays small, while the configuration is ordinary Svelte state.

The configuration

<script>
  import { createGrid } from 'https://cdn.latticegrid.dev/lattice-grid@1.108.0/lattice-grid.esm.min.js';
  import createLatticeAction from 'https://cdn.latticegrid.dev/lattice-grid@1.108.0/modules/svelte.esm.min.js';

  const lattice = createLatticeAction({ createGrid });

  let grid;

  const config = {
    rowKey: 'id',
    columns: [
      { field: 'symbol', title: 'Symbol', layout: { pin: 'start', width: 120 } },
      { field: 'price', title: 'Price', type: 'number' },
      { id: 'delta', title: 'Change', shadow: { of: 'price', kind: 'delta' }, type: 'number', format: { signed: true } },
      { id: 'first', title: 'Baseline', shadow: { of: 'price', kind: 'firstValue' }, type: 'number' },
    ],
    rows,
    // onGrid hands over the live grid the moment it is created, so the button
    // below can rebase it.
    onGrid: (g) => { grid = g; },
  };

  // rebase moves every baseline to the current value, so the deltas start again.
  const markAll = () => grid.statistics.rebase('price');
</script>

<svelte:head>
  <link rel="stylesheet" href="https://cdn.latticegrid.dev/lattice-grid@1.108.0/lattice-grid.min.css">
</svelte:head>

<button on:click={markAll}>Mark all</button>
<div use:lattice={config} style="height: 440px; margin-top: 8px"></div>