Server-Side Row Model - Column Filtering
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
- Grid Filter covers evaluating the Grid Filter on the server
- AdapTableQL Server Evaluation provides instructions for managing the complexity and scope of Expressions
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.
| Property | Type | Description |
|---|---|---|
| columnFilters | ColumnFilter[] | undefined | Currently applied Column Filters |
| gridFilter | string | undefined | Current Grid Filter |
| gridFilterAST | any | AST 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
- This is often coupled with Suppressing Search in the In Filter so that the search can be evaluated on the Server
- Another common practice is Manually Applying Filters so just one server invocation is made with all selected values
- 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
Superstaron theAthletecolumn - and which also gets evaluated on the mock server (using rule:gold > 2 OR (gold + silver + bronze) > 3) - We also provide an implementation for
customInFilterValuesto control which values are displayed in the In Filter - this is also handled on our mock server
- Type
3into theGoldFilter Bar and note how new data is fetched from the server that matches the Filter - Run the
SuperstarCustom Filter on the Athlete column and note how our mock server evaluates it and returns the correct data - Run the
InFilter on the Athlete column and note how the server returns details of all athletes on the server (not just those already loaded)
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.
- This demo uses
isExpressionFunctionAvailableto 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
- Open the operator dropdown in the
GoldFilter Bar and note the reduced list - Open the
AthleteFilter Bar dropdown and see the same subset (only operators relevant to text Columns appear)
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
- This demo is the same Column Filter setup as above, but with
manuallyApplyColumnFilterturned on - The Filter Bar is therefore hidden; Filters are applied only when the Apply Filter button is clicked
- Open the
GoldColumn Filter, enter3, and click Apply Filter — one request is sent to the server - Open the
AthleteIn Filter, select a few values, then click Apply Filter to send them together