Filter
-
✓ Rendered into HTML
-
❏ Rendered into PDF
-
❏ Rendered into Mail
-
❏ Rendered into CSV

Filter DSL is always associated with a Table or a Chart. A bloc cannot contain only a filter.
Code Sample
UiFilterSpecifier f = new UiFilterSpecifier() (1)
f.ui User, { (2)
section "User", { (3)
filterField u.username_ (4)
filterField u.lastName_
filterField u.firstName_
filterField u.manager_, u.manager.username_ (5)
filterField u.mainSubsidiary_
filterField u.allowedSubsidiaries_
filterField u.enabled_
filterFieldExpressionBool "My Team", (6)
new FilterExpression(u.selfObject_,
Operator.IN,
cu.allManagedUsers_),
true
}
}
-
Create the filter
-
pass the object class and the closure containing the specifications of the filter via the
ui
method -
Create a section labeled "User"
-
Add field to the filter, note the underscore at the end of the field name
-
if the field is an object, pass an array with all steps necessary to target the field you want to filter on
-
filterFieldExpressionBool
allow more complex filter
UiFilterSpecifier f = new UiFilterSpecifier()
CmsImage i = new CmsImage(cmsPage: new CmsPage())
f.ui CmsImage, cmsPage ? [id: cmsPage.id] : null, { (1)
section "Image", {
filterField i.hide_
filterField i.filePath_
filterField i.imageType_
}
section "Origin", {
filterField i.cmsPage_, i.cmsPage.name_
filterField i.cmsPage_, i.cmsPage.subsidiary_
filterField i.cmsPage_, i.cmsPage.pageLayout_
filterField i.cmsPage_, i.cmsPage.pageType_
}
}
f
-
We can pass optional parameters to the action
DSL Symbols Hierarchy
DSL Elements
Root
-
ui
: one version allows passing additional parameters to the filter action (see Filter Sample 2)
Inputs
-
filterField
: add object field to be transmitted to the filter action -
filterFieldInverse
: filter objects if another objects point to it. -
filterFieldExpressionBool
: allows changing where clause in the filter action by using FilterExpression, last parameter is the default value.
Structure
-
section
: add a graphical filter section
Table
-
✓ Rendered into HTML
-
✓ Rendered into PDF
-
✓ Rendered into CSV
Code Sample
The right part of the preview corresponds to the DSL sample below. The filter is on the left of the image, see DslDescriptions/FilterDSL.html for the corresponding code.
The table has pagination, it is sorted by default against Date Created column, all columns are sortable except Picture and Roles. One column can contain multiple cells. Date Created is empty for old users, and manager cells are also empty for some users.
User u = new User(manager: new User(), enabled: true)
UiTableSpecifier t = new UiTableSpecifier()
ColumnHeaderFieldSpec.SortableDirection defaultDirection (1)
t.ui User, { (2)
header { (3)
if (!hasSelect) {
column {
fieldHeader "Picture" (4)
}
}
column {
sortableFieldHeader u.username_ (5)
defaultDirection = sortableFieldHeader u.dateCreated_,
ColumnHeaderFieldSpec.DefaultSortingDirection.DESC (6)
}
column {
sortableFieldHeader u.mainSubsidiary_
sortableFieldHeader u.manager_, u.manager.username_ (7)
}
column {
sortableFieldHeader u.lastName_
sortableFieldHeader u.firstName_
}
column {
fieldHeader "Roles"
}
}
def users = taackSimpleFilterService.list(
User, 10, f, null, defaultDirection) (8)
for (User ru : users.aValue) { (9)
row { (10)
Attachment picture = ru.attachments.find {
it.type == Att.PICTURE
}
rowColumn {
rowField attachmentUiService.preview(picture?.id) (11)
}
rowColumn {
rowLink "Edit User", (12)
ActionIcon.EDIT,
this.&userForm as MC, ru.id
rowField ru.username_ (13)
rowField ru.dateCreated_
}
rowColumn {
rowField ru.mainSubsidiary_
rowField ru.manager?.username
}
rowColumn {
rowField ru.lastName_
rowField ru.firstName_
}
rowColumn {
if (!hasSelect)
rowLink "Edit Roles",
ActionIcon.EDIT,
this.&editUserRoles as MC, ru.id, true
rowField ru.authorities*.authority.join(', ')
}
}
}
paginate(10, params.long("offset"), users.bValue) (14)
}
-
Default sort variable storage
-
Pass the class of the object and the specifications of the table
-
Header part of the table specifications
-
Non-sortable field header
-
Sortable field header, notice the underscore at the end of the variable name
-
Initialise default sort
-
If the field contains an object, the path to the value to sort is specified via an array
-
taackSimpleFilterService
, responsible for sorting, filtering and pagination -
Iterate over objects
-
Specify a row
-
Cell containing only 1 value, it is not mandatory to pass underscore version
-
Icon that will call
userForm
on user displayed into the row -
Simple value added to a cell
-
Pagination
ActionIcon can be modified by ActionIconModifier
Table style is specified by Style
an optional parameter on row
or rowField
element.