Defining Column Filters
Summary
- Column Filters are defined inside a Layout
- They can be defined in both Table and Pivot Layouts
Column Filters can be provided at design-time in given Layouts via Layout Initial State.
This can include Column Filters which use System Predicates and those which use Custom Predicates.
Find Out More
- See Defining Table Layouts for details on defining Column Filters in Layouts
- The System Predicate Guide lists all the Predicates which AdapTable provides for Filters
- The Custom Predicate Guide shows Developers how to provide Custom Predicates which can then be used in Filters
Developer Guide
Defining Columns Filters in a Layout
Column Filters are provided in a Layout as follows:
// Provide 3 Column Filters
// a. In (System Predicate) on currency Column for 'USD' and 'EUR'
// b. GreaterThan (System Predicate) on price Column
// c. 'post-takeover' (Custom Predicate) on orderDate Column
// The Custom Predicate is defined in Predicate Options
const adaptableOptions: AdaptableOptions = {
const initialState: InitialState = {
Layout:{
CurrentLayout: 'Filtered Layout',
Layouts: {
Name: 'Filtered Layout',
TableColumns: ['currency', 'orderData', 'github_watchers', 'price'],
ColumnFilters: [
{
ColumnId: 'currency',
Predicates: [
{
PredicateId: 'In',
Inputs: ['USD', 'EUR']
}]
},
{
ColumnId: 'price',
Predicates: [
{
PredicateId: 'GreaterThan',
Inputs: ['500']
}
],
},
{
ColumnId: 'orderDate',
Predicates: [
{
PredicateId: 'post_takeover'
}
],
},
],
}
},
predicateOptions: {
customPredicateDefs: [
{
id: 'post_takeover',
label: 'Post Takeover',
columnScope: { DataTypes: ['date'] },
moduleScope: ['columnFilter', 'alert'],
handler(params: PredicateDefHandlerContext) {
return (params.value as Date) > new Date('2019-09-21');
},
},
],
}
};Create a ColumnFilters property inside a Layout
This is an array with one item for each Column Filter to be provided
Supply the ColumnId for each Filter.
Specify which Predicate to use:
- The
PredicateIdproperty must always be supplied - Provide
Inputsif required by the chosen Predicate
A Column Filter can also reference a user-provided Custom Predicate.
Again, provide the ColumnId and the PredicateId property (and any inputs).
Caution
The Column in the Filter must be appropriate to the columnScope defined in the Predicate
Create the Predicate in customPredicateDefs property in Predicate Options.
Make sure that the moduleScope includes 'columnFilter' if you want to use it in a Column Filter and provide the appropriate columnScope.
AdapTableQL uses the handler function to evaluate and apply the filter.
Find Out More
See Custom Filters Guide and Custom Predicate Defs for full details