Value Getters

Normally columns are configured with field attributes, so the column knows what field to take values from in the
data. Instead of providing field it is possible to provide a valueGetter instead. A Value Getter is a function that
gets called allowing values to be pulled from literally anywhere, including executing any expressions you wish along the
way.

You should use field most of the time. Use value getters when retrieving the data requires more logic, including
executing your own expressions (similar to what a spreadsheet would do).

# example value getter, adds two fields together
columnDefs = [
  {
    "valueGetter": {"function": "params.data.firstName + params.data.lastName;"},
  },
]

All valueGetters must be pure functions. That means, given the same state of your data, it should consistently return
the same result. This is important as the grid will only call your valueGetter once during a redraw, even though the
value may be used multiple times. For example, the value will be used to display the cell value, however it can
additionally be used to provide values to an aggregation function when grouping, or can be used as input to another
valueGetter via the params.getValue() function.

Example Value Getters

The example below demonstrates valueGetter. The following can be noted from the demo:

Header Value Getters

Use headerValueGetter instead of columnDefs.headerName to allow dynamic header names.

The parameters for headerValueGetter differ from standard valueGetter as follows:

See the AG Grid documentation for an
example of headerValueGetter used in different locations, where you can change the header name depending on where the
name appears.

Filter Value Getters

By default, the values supplied to the filter are retrieved from the data based on the field attribute. This can be
overridden by providing a filterValueGetter in the Column Definition as shown below. This is similar to using a normal
Value Getter, but is specific to the filter.

Value Cache

The value cache is used for the results of value getters. If you are not using value getters, then you do not need the
value cache.

Each time the grid requires a value from a value getter, the value getter is executed. For most use cases, this will not
be an issue, as value getters will execute quickly and not have any noticeable performance implications for your
application. However sometimes you might implement time-intensive tasks in your value getters. If this is the case, then
you can opt to turn on the value cache to store the results of the value getters.

When the value cache is turned on, each time a value getter is executed, its result is stored in the value cache. If the
data in the grid has not changed since the last time the value getter was used, then the value is retrieved from the
cache instead of executing the value getter again.

This value cache is for advanced users who have time-consuming value getters and want to speed up their applications by
introducing a cache to reduce the number of times value getters get executed.

See more information and examples in
the AG Grid documentation