GRID FEATURE · PRO

Formula calculation

Formulas evaluate strings beginning with = and display the result in a cell. For example, =SUM(A1:A3) references the first column in the original column definitions and the first three source rows.

How it works and when to use it

A1 coordinates do not follow the sorted display order. Formulas use the original data order and columnDefs order even after users sort rows or move columns.

Using this feature in a product requires the Pro package and a valid license. Matching setting names do not enable Pro features in Community.

In the code, grid is the Grid element prepared in the installation chapter. Check each example's data and settings, and implement the app functions and server endpoints for your project.

Example 1. Calculate an amount from price and quantity

Start with three columns that make formula coordinates easy to follow.

javascript
grid.columnDefs = [
  { field: 'quantity', headerName: 'Quantity', editable: true, editor: 'number' },
  { field: 'price', headerName: 'Unit price', editable: true, editor: 'number' },
  { field: 'amount', headerName: 'Amount' },
];
grid.rowData = [{ id: 'a', quantity: 3, price: 100, amount: '=A1*B1' }];
grid.formulas = true;

Verify the result: The amount displays 300. Editing the quantity recalculates the dependent amount.

Example 2. Compare results with formula text

Show the formula text and formula bar when calculations differ from your expectations.

javascript
grid.showFormulas = true;
grid.formulaBar = true;

Verify the result: The formula cell displays =A1*B1. Set showFormulas back to false after reviewing it to display the result.

Example 3. Review multiple sheets and dynamic arrays

When connecting multiple Grids as a workbook, use getWorkbookPropagationState() and getWorkbookSnapshotReport() to inspect connections and propagation. Before using dynamic arrays, review the dedicated applySpillFormula() input contract and conflict results.

Verify the result: If existing values occupy the spill area, do not force the array result over them. Distinguish rejected operations, conflicts, and unrendered cells when explaining the result to users.

Combining features and troubleshooting

Formula text and calculated results are separate. Decide which you need for saving, copying, and exporting, then verify the output.

Do not assume every Excel function is supported. Test the function names and error results in the formulas you use, and avoid circular references.

Related reading