Server-Side Row Model - Calculated Columns
Summary
- Standard and Observable Calculated Columns evaluate on the client as each row renders
- Aggregated, Cumulative, Quantile and Window Calculated Columns need the calculation to be performed on the server
Calculated Columns can work automatically when using AG Grid's Server-Side Row Model.
However this does depend on the complexity of the Calculation.
Standard
Standard Calculated Columns operate as normal in the Server-Side Row Model.
Note
This is because they use Standard Expressions which operate on a single row and evaluate as the row is rendered
Adding, editing or deleting a Calculated Column keeps the rows already loaded from the server; the new values are evaluated as the rows render.
Caution
While a Column Filter or Grid Filter is active, a Calculated Column change reloads the rows from the server, as the filtered rows may change
- This demo includes 3 Calculated Columns -
Total,Most,Points - All are standard (i.e. single-row) Calculated Columns and all work out of the box when using Server-Side Row Model
Observable
Observable Calculated Columns also evaluate on the client.
They use Observable Expressions which read that row's change history — and not other rows.
Caution
- AdapTable only records history for changes it has seen in this session, edits,
updateGridData,setCellValueetc. - Ticks that happen only on the server — or a row that is paged out and fetched again — have no history on the client
Hint
For server-authoritative history (e.g. how many times a price ticked in the last 5 minutes across the full dataset), evaluate the Expression on the server and return the value, as with Aggregated Columns.
- This demo ticks
Goldon visible rows so AdapTable can record client-side change history - It includes 3 Observable Calculated Columns which evaluate as each row renders:
Gold Ticks—CHANGE_COUNT{[gold], WITHIN(2m)}Previous Gold—PREVIOUS{[gold]}Net (30s)—NET_CHANGE{[gold], WITHIN(30s)}
liveRefreshIntervalMsis set so the windowed values keep updating as time passes
- Watch
Goldflash as it ticks, and seeGold TicksandPrevious Goldupdate on the same row - Scroll so new rows load — they start with empty history until they tick
Aggregated and Window
The more complex type of Calculated Columns (Aggregated, Cumulative, Quantile and Window) do not work out of the box when using the Server-Side Row Model.
Note
- This is because they use Aggregated Expressions (including Window Expressions)
- These operate over multiple rows, not all of which will be present on the client
When this is the case, you will need to follow a 2-stage process:
- evaluate the Expression on the Server
- Pass AdapTable the value returned from the server to render