Creating Filterable Row Styles
How to leverage Named Queries to create full-row Conditional Styles, and provide custom Dashboard Buttons and Menu Items to easily filter them using the Grid Filter
Feedback
- This Blog post, and accompanying demo, was inspired by an AdapTable Help Ticket
- If you have an AdapTable or AG Grid use case that you are struggling to meet, please contact us
Our User's Question
We were recently contacted by an AdapTable user with an interesting request.
She asked how she could achieve the following 2-step process in AG Grid:
-
enable run-time users to create full-row styles (using a custom Rule)
-
help these users easily to filter the Grid using the created styles
Our Solution and Demo
In response, we provide a demo illustrating how this is possible using these AdapTable functions:
- Named Queries (wrapping AdapTableQL Expressions)
- Grid Filter
- Conditional Styles
- Custom Column Menu and Context Menu Items
- Custom Toolbar displaying Adaptable Buttons
- Adaptable API
Important
Our demo uses only existing AdapTable functionality, UI components and API methods
- The Grid contains 3 full row Conditional Styles
- Clicking a Dashboard button (or selecting a custom Column or Context Menu Item) will filter the Grid by that Style
Named Queries
The key is to leverage Named Queries, a powerful, and often under-used, AdapTable feature.
As the name imples, Named Queries are simply named AdapTableQL Boolean Expressions.
Note
By giving the Query a Name, it can easily be shared and re-used in multiple modules (see below)
In our example we create 3 Named Queries, each of which groups a set of Frameworks.
Hint
The Named Queries Expressions use the AdapTableQL IN Expression Function

We then re-use each Named Query in a number of ways.
Conditional Styles
We configure a separate full-row Conditional Style for each Named Query.
Each Conditional Style Rule wraps a different Named Query and provides a distinct style.
Hint
- The Conditional Style expressions themselves are very straightforward
- They simply leverage the AdaptableQL QUERY expression function which wraps a Named Query
Rule: {
BooleanExpression: 'QUERY("Frequently Used")',
},
UI Components
Next we leverage 3 of the UI components provided by AdapTable.
Column Menu
We provide a Custom Column Menu Item in each Column Menu.
The Menu Item lists all the Named Queries, as sub menu items, and then filters the Grid using the value selected.

Context Menu
We also provide a Custom Context Menu Item in each Grid Cell.
The Context Menu Item works out which Named Query is associated with that Grid Cell's row.
When the menu item is selected, it filters the Grid by that Named Query.

Dashhboard Toolbars and Buttons
Finally, we create a Custom Toolbar to display in the Dashboard.
We dynamically render an Adaptable Button for each Named Query.
When the Button is clicked, we filter the Grid by that Named Query.
We also provide a Clear Filter Button to remove any filtering.
Important
- Because we want to create the Buttons dynamically we don't configure them in Dashboard Options
- Instead we create them on the fly by subscribing to 2 of the most frequently used Adaptable Events:
- Adaptable Ready - to create the buttons when AdapTable initialises for the first time
- Adaptable State Changed - to recreate if Format Columns or Named Queries change in State

Grid Filter
The last element in our demo is the Grid Filter - a powerful, cross-column filtering module.
Note
The Grid Filter runs in parallel with Column Filters, enabling the richest DataGrid functionality available
At its heart, the Grid Filter is an intuitive wrapper around an AdapTableQL Boolean Expression.
This makes it trivial to filter the Grid using our Named Queries.
Each time the user selects a custom Menu Option, or clicks a Dashboard Button, the onClick functions simply create, and set, a new Grid Filter Expression dynamically.
Hint
We leverage the useful setGridFilterExpressionUsingNamedQuery function in Grid Filter Api:
gridFilterApi.setGridFilterExpressionUsingNamedQuery(query);
Extensibility
As noted above, we create, and display the Dashboard Buttons dynamically.
This provides our demo with one big advantage: each time we create a new Format Column which wraps a Named Query, a new Dashboard button will automatically appear.
Note
- In our demo we deliberately leave 3 Frameworks without a Name:
backbone,gatsby&knockout - Below we create a new Named Query, and associated Style, and a new Button dynamically appears