Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/prettier.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions .run/Nx dev.run.xml

This file was deleted.

12 changes: 12 additions & 0 deletions documentation/ag-grid-docs/src/content/docs-nav/nav.json
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,18 @@
"title": "Formula Editor",
"path": "formula-editor-component",
"isEnterprise": true
},
{
"type": "item",
"title": "Formula Reference",
"path": "formula-reference",
"isEnterprise": true
},
{
"type": "item",
"title": "Custom Functions",
"path": "formula-custom-functions",
"isEnterprise": true
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ As in default editing, cell and row editing events get fired as normal when edit

When in Batch Editing, the `cellValueChanged`, `rowValueChanged` events are fired **after** the batch edit is committed.

### Pending Values

When Batch Editing is active, edits made to cells are stored as **pending values**. These pending values are not immediately applied to the underlying data model. Instead, they are held in a temporary state until the batch is either committed or canceled.

Pending values are used by display features such as cell rendering and copy/paste but they are not used for data based features such as sorting, filtering, grouping or aggregation until the batch is committed.

The `api.getCellValue()` method can retrieve cell values at different stages using the `from` parameter:

- `'edit'` (default): Current editing value, including live editor typing and pending batch values
- `'batch'`: Pending batch value, excluding live editor typing
- `'data'`: Actual stored data value, ignoring all edit state

{% apiDocumentation source="grid-api/api.json" section="miscellaneous" names=["getCellValue"] /%}

## Customisation

### Custom Renderers & Editors
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
title: "Custom Functions"
enterprise: true
---
Custom formula functions let you extend the engine with domain-specific logic and reusable calculations.

## Formula Functions API

Custom functions are provided through the `formulaFuncs` grid option.

{% apiDocumentation source="grid-options/properties.json" section="formulas" names=["formulaFuncs"] /%}

## Simple Example

The example below registers `CUSTOMSUM`, which iterates over all values passed to the function (including ranges) and returns their sum.

{% gridExampleRunner title="Simple Iterator" name="formulas-simple-iterator" exampleHeight=390 /%}

```{% frameworkTransform=true %}
const gridOptions = {
columnDefs: [
{ field: 'sales' },
{ field: 'calculated', allowFormula: true },
],
formulaFuncs: {
CUSTOMSUM: {
func: (params) => {
let total = 0;
for (const value of params.values) {
total += value;
}
return total;
},
},
},
};
```

## Error Handling

Your function should throw when arguments are invalid. Errors are surfaced in the grid and propagate through dependent formulas.

{% gridExampleRunner title="Custom Errors" name="formulas-custom-errors" exampleHeight=430 /%}

{% note %}
When a function (or a referenced cell) throws an error, the cell displays `#ERROR!` and hovering over the cell displays the thrown error message. Errors also propagate to dependent formula cells.
{% /note %}

## Complex Example

This example shows `COUNTEQ`, which receives a range and a value and counts matches. It uses `params.args` to validate argument types and handle ranges explicitly.

{% gridExampleRunner title="Contextual Iterator" name="formulas-context-iterator" exampleHeight=390 /%}

## Best Practices

- Validate argument counts and types early.
- Prefer iterators (`params.values`) for large ranges to avoid unnecessary allocations.
- Keep functions pure and fast to avoid performance issues on large grids.

See [Formula Reference](./formula-reference/) for built-in functions that can inspire custom implementations.
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
title: "Formula Reference"
enterprise: true
---
This page lists all supported operators and built-in functions for quick reference. For syntax usage and examples, see the main [Formulas](./formulas/) page.

## Mathematical Operators

| Symbol | Description |
| ------ | ----------- |
| `+` | Addition, can be used to add two numbers, or add days to a Date |
| `-` | Subtraction, can be used to subtract two numbers, or subtract days from a Date |
| `*` | Multiplication, can be used to multiply two numbers |
| `/` | Division, can be used to divide two numbers |
| `^` | Exponentiation, can be used to raise a number to a power |
| `&` | Concatenation, can be used to join two strings |
| `=` | Equal to, can be used to compare two values |
| `<>` | Not equal to, can be used to compare two values |
| `>` | Greater than, can be used to compare two values |
| `<` | Less than, can be used to compare two values |
| `>=` | Greater than or equal to, can be used to compare two values |
| `<=` | Less than or equal to, can be used to compare two values |

## Provided Functions

**Numeric Functions**

| Function | Description |
| -------- | ----------- |
| `SUM(arg1, arg2, ...)` | Returns the sum of all arguments. |
| `SUMIF(range, criteria, [sum_range])` | Returns the sum of values in `sum_range` where the corresponding values in `range` meet the `criteria`. If `sum_range` is not provided, `range` is used for summation. |
| `PRODUCT(arg1, arg2, ...)` | Returns the product of all arguments. |
| `MIN(arg1, arg2, ...)` | Returns the minimum value among the arguments. |
| `MAX(arg1, arg2, ...)` | Returns the maximum value among the arguments. |
| `AVERAGE(arg1, arg2, ...)` | Returns the average of all numeric values among the arguments. |
| `MEDIAN(arg1, arg2, ...)` | Returns the median of all numeric values among the arguments. |
| `POWER(arg1, arg2)` | Returns the result of raising the first argument to the power of the second argument. |
| `RAND()` | Returns a random number between 0 and 1. |

**Date Functions**

| Function | Description |
| -------- | ----------- |
| `NOW()` | Returns a date object representing the current date and time. |
| `TODAY()` | Returns a date object representing the current date with the time set to 00:00:00. |

**Text Functions**

| Function | Description |
| -------- | ----------- |
| `CONCAT(arg1, arg2, ...)` | Concatenates all arguments into a single string. |

**Logical Functions**

| Function | Description |
| -------- | ----------- |
| `IF(condition, value_if_true, value_if_false)` | Returns `value_if_true` if the condition is true, otherwise returns `value_if_false`. |

**Counting Functions**

| Function | Description |
| -------- | ----------- |
| `COUNT(arg1, arg2, ...)` | Returns the count of numeric values among the arguments. |
| `COUNTA(arg1, arg2, ...)` | Returns the count of non-empty values among the arguments. |
| `COUNTBLANK(arg1, arg2, ...)` | Returns the count of empty values among the arguments. |
| `COUNTIF(range, criteria)` | Returns the count of values in the range that meet the criteria. |

## Error Codes

| Error | Description |
| -------- | ----------- |
| `#REF!` | Formula contains invalid cell reference |
| `#NAME?` | Formula contains invalid operation |
| `#CIRCREF!` | Formula contains circular reference |
| `#PARSE!` | Could not parse formula value |
| `#VALUE!` | Formula contains value of the wrong type (e.g. non-numeric arguments to functions) |
| `#DIV/0!` | Formula results in a division by zero |
| `#ERROR!` | Formula contains some other kind of error |
Loading
Loading