Server-Side Row Model - Column Filtering

View as Markdown

Summary

  • Column Filters need to be evaluated remotely when using the Server-Side Row Model
  • AdapTable provides functions that help developers retrieve the latest Filter state (to pass in to the server)
  • Custom Filters, In Filter values, and the set of available operators can all be tailored for a remote implementation

When using the Server-Side Row Model, AG Grid will not perform any filtering.

Note

  • Quick Search works fully in Server-Side Row Model, both for data already in the Grid and new data as it is fetched
  • However Quick Search as Filter will not work (unless you implement it yourself)

Instead AG Grid hands off those tasks to developer to perform on the server.

Caution

When using the Server-Side Row Model, it is the developer's responsibility to perform the actual filtering on the server

In practice this requires developers to provide a server equivalent of AdapTableQL to evaluate any Column Filters.

Find Out More

Getting Filter State

When using the Server-Side Row Model, you need to fetch the current filter (and sort) state from AdapTable inside the getRows function.

Note

The Grid Filter Applied and Column Filter Applied Events still fire, but are rarely subscribed to when using the SSRM

This is most easily done through the getAdaptableFilterState function in the State API section of Adaptable API.

It returns an AdaptableFilterState object defined as follows:

Filters currently applied.

gridFilter is the Grid Filter expression, absent when there is none. columnFilters are the Column Filters in the current layout.

PropertyTypeDescription
columnFiltersColumnFilter[] | undefinedCurrently applied Column Filters
gridFilterstring | undefinedCurrent Grid Filter
gridFilterASTanyAST for Current Grid Filter

Columns Filters

Column Filters can still be set and applied when using the Server-Side Row Model.

But instead of the Filters being evaluated by AdapTable, they are evaluated by developers on the server.

Hint

This can also include Custom Filters, which will also be evaluated remotely in a bespoke implementation

In Filter Values

AdapTable provides an In Filter, which allows users to select from a list of values for the Column.

By default, AdapTable simply lists all distinct values currently visible in the Grid's data source for the Column.

This is fine when using the Client-Side Row Model - as all data has been loaded - but can be unsatisfactory for the Server-Side Row Model, since it can result in a unnecessarily reduced list of values.

For this reason it is common when using the SSRM to implement the customInFilterValues property in Filter Options in order to provide a fuller list of values.

Note

SSRM - Column Filtering
Fork
  • The example shows how AdapTable Column Filters can still be used while using Server-Side Row Model:
  • We convert current Column Filter and Grid Filter Expressions to AST and pass that to our mock server to evaluate
  • We add a Custom Filter called Superstar on the Athlete column - and which also gets evaluated on the mock server (using rule: gold > 2 OR (gold + silver + bronze) > 3)
  • We also provide an implementation for customInFilterValues to control which values are displayed in the In Filter - this is also handled on our mock server
Try It Out
  • Type 3 into the Gold Filter Bar and note how new data is fetched from the server that matches the Filter
  • Run the Superstar Custom Filter on the Athlete column and note how our mock server evaluates it and returns the correct data
  • Run the In Filter on the Athlete column and note how the server returns details of all athletes on the server (not just those already loaded)
Loading demo…

Limiting Available Operators

By default AdapTable offers every boolean Expression Function (operator) relevant to each Column's Data Type.

This means a bespoke server implementation needs to translate every operator into something meaningful.

Accordingly, AdapTable allows developers to limit which operators are available in order to make the server implementation more manageable.

This can be done using the isExpressionFunctionAvailable function in Expression Options and can be set globally, per Module, or per Column.

SSRM - Limited Operators
Fork
  • This demo uses isExpressionFunctionAvailable to offer only a small, server-friendly set of Column Filter operators:
    • EQ, NEQ, GT, GTE, LT, LTE, IN, CONTAINS, IS_BLANK
  • Everything else (REGEX, BETWEEN, STARTS_WITH, date predicates, etc.) is hidden, so the server only needs to translate this subset
Try It Out
  • Open the operator dropdown in the Gold Filter Bar and note the reduced list
  • Open the Athlete Filter Bar dropdown and see the same subset (only operators relevant to text Columns appear)
Loading demo…

Manually Applying Filters

When evaluating Column Filters on the server, it is common to turn on Manually Applying Filters.

This ensures that only one call to the server is made after all selections are complete.

Note

  • AdapTable disables the Filter Bar for any Column where Manually Applying Filters is turned on
  • It shows an Apply Filter button in the Filter Form instead
SSRM - Manually Apply Filters
Fork
  • This demo is the same Column Filter setup as above, but with manuallyApplyColumnFilter turned on
  • The Filter Bar is therefore hidden; Filters are applied only when the Apply Filter button is clicked
Try It Out
  • Open the Gold Column Filter, enter 3, and click Apply Filter — one request is sent to the server
  • Open the Athlete In Filter, select a few values, then click Apply Filter to send them together
Loading demo…