Skip to content

Calculated Columns

Enterprise

A calculated column computes its value from the rest of the row — a total from revenue + mrr, a ratio, a category — without that value living in your source data. It’s an enterprise feature built with calculatedColumn, which returns a normal column you drop into columns:

import { calculatedColumn } from '@zengrid/enterprise';
const grid = new Zengrid(el, {
columns: [
{ field: 'revenue', header: 'Revenue' },
{ field: 'mrr', header: 'MRR' },
calculatedColumn({
field: 'total',
header: 'Total',
renderer: currency,
value: ({ getValue }) => getValue('revenue') + getValue('mrr'),
}),
],
});

The value function receives getValue(field) to read any other column in the same row, plus the raw data and row index. Anything else you set — renderer, width, align — applies like a normal column.

Each tab derives a different column. Edit the value function and the grid recomputes as you scroll.

value: ({ getValue }) => getValue('revenue') + getValue('mrr'). Give it the currency renderer and right align, like any column.