User collection filters allow the user to filter the results of a collection by filtering one or more columns to certain value(s). Each filter presents a field by which that column can be filtered. Filters can also be backed by complex logic, filtering on more than one column or by a different mechanism. Note though filters are applied after a collection has been populated. For example if added to the results group on a lookup, they would be applied after the initial database search.
User collection filters build off the current collection filter support.
Currently the UIF contains the following:
The collection group contains a List of Collection Filters that can be configured with the collection group. These filters are applied in list order during the apply model phase. A collection line must pass all filters to be displayed.
Filters the collection to only display active lines. The framework will enable this filter by default when the collection line class implements Inactivatable. A button is presented to the user to enable the display of inactive lines.
Filters the collection based on a configured expression language statement. Each line is evaluated against the el expression (which should return a boolean). The expression must evaluate to true in order for the line to be displayed.
User Collection Filters
The following describes the enhancements needed in order to support user collection filters.
Extends CollectionFilter adding the following:
The getUserFilter method will return the Field that will be presented to the user for modifying the filter.
Radio Input Field - User selects the values for a column to display
Checkbox/Button Toggle - User toggles the filter on/off
This can return a FieldGroup to render multiple fields/controls if needed.
A group property will be added to CollectionGroup for displaying the filters. This will allow the configuration for how the filters will be displayed (such as layout). For each filter configured on the collection group, the corresponding field to display will be retrieved and inserted into the filter group's items list in the configured list order.
Defaults will be set using BoxLayout Vertical layout (so the filters are displayed in a column). The filter group will be rendered to the left of the collection group by the collectionGroup template.
The filter fields will be setup to trigger a refresh of the collection group when there value changes. The selected filter values will be updated on the form, so when the collection runs through the lifecycle it will be updated based on those selections. The updated filter value should be retrieved in the filter method and the collection filtered appropriately.
Filter Value Binding
UifFormBase will contain a Map that holds the filter values. The map will be keyed by the collection binding path (similar to the new collection lines map), with a List as the Map value that contains the value(s) for each filter. Filters can extend UserCollectionFilterBase which will contain a helper method for retrieving the current filter value.
To support client side filtering the following would be needed:
1. Add method to UserCollectionFilter to get the script that will perform the filtering:
2. The collection data would need exposed to script. In the collection group template a call could be made to export the data as a JS array.
3. When a filter value changes, pass the JS array and the current filter value(s) to the configured client side callback.
4. The callback should return the line index to show (similar to the server side filter method).
5. In the case of stacked layout, for the lines that should be filtered, we need to determine the group id to hide. This could possibly be exposed to script when doing the data export. This needs more analysis.
6. In the case of table layout, we need to hook into datatables filtering to hide the rows. This needs more analysis.
Filter to filter the collection based on the values for a column. The user will be presented with a RadioGroup control containing all the values for that column that are present in the collection which can be used to filter the collection. To use the property name just needs to be configured and the filter will take care of building the filter field and doing the actual filtering (server side only).
propertyName - name of the property in the collection the filter should be created for