Server-Side Row Model - Calculated Columns

View as Markdown

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

SSRM - Standard Calculated Columns
Fork
  • 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
Loading demo…

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, setCellValue etc.
  • 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.

SSRM - Observable Calculated Columns
Fork
  • This demo ticks Gold on 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)}
  • liveRefreshIntervalMs is set so the windowed values keep updating as time passes
Try It Out
  • Watch Gold flash as it ticks, and see Gold Ticks and Previous Gold update on the same row
  • Scroll so new rows load — they start with empty history until they tick
Loading demo…

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

When this is the case, you will need to follow a 2-stage process:

  1. evaluate the Expression on the Server
  2. Pass AdapTable the value returned from the server to render