Skip to main content

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)

PropertyTypeDefaultDescription
caseSensitivebooleanfalseBy default, set filtering is case-insensitive. Set this to true to make text filtering case-sensitive.
textFormatterBiFunction<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.

Grid using Server Side Set Filter

  • Product uses default set filter
  • Portfolio is case-sensitive
  • Book uses set filter with custom textFormatter - accent removal
  • Submitter Id uses set filter with numbers
  • Birth Date uses set filter with dates
  • Is Sold uses set filter with boolean values + Blank value can be selected
  • Backend source code available here