demo D197
Running totals
The one derived value that depends on the display order
running: { of, kind: 'total' }
Loading a live grid…
The configuration
import * as ng from '@angular/core';
import { Component } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { createGrid } from '@toclocoinc/lattice-grid';
import '@toclocoinc/lattice-grid/css';
import createLatticeGrid from '@toclocoinc/lattice-grid/modules/angular';
const { LatticeGridComponent } = createLatticeGrid({ ng, createGrid });
const 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' } },
];
const rows = [/* dated amounts */];
@Component({
selector: 'app-root',
standalone: true,
imports: [LatticeGridComponent],
template: '<lattice-grid [config]="grid" style="display:block;height:460px"></lattice-grid>',
})
export class AppComponent {
grid = {
rowKey: 'id',
columns: columns,
state: { sort: [{ col: 'date', dir: 'asc' }] },
rows: rows,
};
}
bootstrapApplication(AppComponent);