Set Filter
The Set Filter takes inspiration from Excel's AutoFilter and allows filtering on sets of data.
Using Set Filter
Set filter is represented by class AgSetColumnFilter.
ColDef colDef = ColDef.builder()
.field("product")
.filter(new AgSetColumnFilter())
.build()
Set Filter Parameters
Set Filters are configured though the filter params (SetFilterParams class)
| Property | Type | Default | Description |
|---|---|---|---|
caseSensitive | boolean | false | By default, set filtering is case-insensitive. Set this to true to make text filtering case-sensitive. |
textFormatter | BiFunction<CriteriaBuilder, Expression<String>, Expression<String>> | — | Formats the text before applying the filter compare logic. Useful if you want to substitute accented characters, for example. Works only if the column is string type. Same as in text filter. |
Example of using filter parameters.
ColDef colDef = ColDef.builder()
.field("product")
.filter(new AgSetColumnFilter()
.filterParams(
SetFilterParams.builder()
.caseSensitive(false)
.textFormatter((cb, expr) => {
Expression<String> newExpression = expr;
// lower input
newExpression = cb.lower(newExpression);
// Remove accents
newExpression = cb.function("TRANSLATE", String.class, newExpression,
cb.literal("áéíóúÁÉÍÓÚüÜñÑ"),
cb.literal("aeiouAEIOUuUnN"));
return newExpression;
})
.build()
)
)
.build()
Set Filter Model
Set filter model is represented by SetFilterModel class.
Supplying Filter Values
Since the Server-Side Row Model does not have all data loaded in the browser, you must provide the list of unique values for the set filter manually.
The adapter provides the supplySetFilterValues method, which automatically
fetches distinct sorted values from the database for a given column.
Grid using Server Side Set Filter
Productuses default set filterPortfoliois case-sensitiveBookuses set filter with customtextFormatter- accent removalSubmitter Iduses set filter with numbersBirth Dateuses set filter with datesIs Solduses set filter with boolean values + Blank value can be selected- Source code for this grid available here
- Backend source code available here
Loading grid...