FilteringTable
Extension of Vaadin Table, provides a filter bar below the table header
FilterTable is an extension of the Table component in Vaadin. FilterTable is available for both Vaadin 6 and Vaadin 7 (versions postfixed with '.v7').
Added features: • Provides automatically generated filter components between the table header and body • Automatically filters enum, boolean and date properties • Other properties are filtered as a string • Numeric properties can optionally be filtered with a comparator popup • Allows developer to provide own filter implementation for any property • Allows developer to decorate the numeric, date, enum and boolean filter components with custom captions and icons • Provides integration of PagedTable add-on with the filter bar • Provides integration of TreeTable with the filter bar
NOTE: The Vaadin 6 version of this addon requires Vaadin 6.8.7 or later, starting from add-on version 0.8.4.
NOTE: The Vaadin 7 version of this addon requires Vaadin 7.0.1 or later, starting from add-on version 0.8.4.v7.
NOTE: The Vaadin 7 version of this addon requires Vaadin 7.1.0 or later, starting from add-on version 0.9.0.v7.
NOTE: The Vaadin 7 version of this addon requires Vaadin 7.2.0 or later, starting from add-on version 0.9.9.v7.
NOTE: The Vaadin 7 version of this addon requires Vaadin 7.3.0 or later, starting from add-on version 0.9.11.v7.
Known issues: Please see the issue list in the linked GitHub page.
Please report any issues in the linked forum thread or GitHub - not the review comments. Thank you.
Please note that only the latest versions of FilteringTable for both Vaadin 6 and Vaadin 7 are supported. I will not backport bugfixes to earlier releases.
Sample code
package com.example.filtertabledemo; import org.tepi.filtertable.FilterGenerator; import com.vaadin.data.Container.Filter; import com.vaadin.data.util.filter.Compare; public class DemoFilterGenerator implements FilterGenerator { @Override public Filter generateFilter(Object propertyId, Object value) { if ("id".equals(propertyId)) { /* Create an 'equals' filter for the ID field */ if (value != null && value instanceof String) { try { return new Compare.Equal(propertyId, Integer.parseInt((String) value)); } catch (NumberFormatException ignored) { // If no integer was entered, just generate default filter } } } // For other properties, use the default filter return null; } }
package com.example.filtertabledemo; import java.util.Locale; import org.tepi.filtertable.FilterDecorator; import com.example.filtertabledemo.FiltertabledemoApplication.State; import com.vaadin.terminal.Resource; import com.vaadin.terminal.ThemeResource; public class DemoFilterDecorator implements FilterDecorator { @Override public String getEnumFilterDisplayName(Object propertyId, Object value) { if ("state".equals(propertyId)) { State state = (State) value; switch (state) { case CREATED: return "Order has been created"; case PROCESSING: return "Order is being processed"; case PROCESSED: return "Order has been processed"; case FINISHED: return "Order is delivered"; } } // returning null will output default value return null; } @Override public Resource getEnumFilterIcon(Object propertyId, Object value) { if ("state".equals(propertyId)) { State state = (State) value; switch (state) { case CREATED: return new ThemeResource("../runo/icons/16/document.png"); case PROCESSING: return new ThemeResource("../runo/icons/16/reload.png"); case PROCESSED: return new ThemeResource("../runo/icons/16/ok.png"); case FINISHED: return new ThemeResource("../runo/icons/16/globe.png"); } } return null; } @Override public String getBooleanFilterDisplayName(Object propertyId, boolean value) { if ("validated".equals(propertyId)) { return value ? "Validated" : "Not validated"; } // returning null will output default value return null; } @Override public Resource getBooleanFilterIcon(Object propertyId, boolean value) { if ("validated".equals(propertyId)) { return value ? new ThemeResource("../runo/icons/16/ok.png") : new ThemeResource("../runo/icons/16/cancel.png"); } return null; } @Override public Locale getLocale() { // will use the application locale return null; } @Override public String getFromCaption() { return "Start date:"; } @Override public String getToCaption() { return "End date:"; } @Override public String getSetCaption() { // use default caption return null; } @Override public String getClearCaption() { // use default caption return null; } }
package com.example.filtertabledemo; import java.util.Calendar; import java.util.Date; import java.util.Random; import org.tepi.filtertable.FilterTable; import com.vaadin.Application; import com.vaadin.data.Container; import com.vaadin.data.util.IndexedContainer; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class FiltertabledemoApplication extends Application { /** * Example enum for enum filtering feature */ public enum State { CREATED, PROCESSING, PROCESSED, FINISHED; } private FilterTable filterTable; @Override public void init() { Window mainWindow = new Window("FilterTable Demo Application"); setMainWindow(mainWindow); /* Create FilterTable */ filterTable = buildFilterTable(); VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setSizeFull(); mainLayout.setSpacing(true); mainLayout.setMargin(true); mainLayout.addComponent(filterTable); mainLayout.setExpandRatio(filterTable, 1); mainLayout.addComponent(buildButtons()); mainWindow.setContent(mainLayout); } private FilterTable buildFilterTable() { FilterTable filterTable = new FilterTable(); filterTable.setSizeFull(); filterTable.setFilterDecorator(new DemoFilterDecorator()); filterTable.setFilterGenerator(new DemoFilterGenerator()); filterTable.setContainerDataSource(buildContainer()); filterTable.setFiltersVisible(true); return filterTable; } private Component buildButtons() { HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSizeUndefined(); buttonLayout.setSpacing(true); Button showFilters = new Button("Show filter bar"); showFilters.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { filterTable.setFiltersVisible(true); } }); buttonLayout.addComponent(showFilters); Button hideFilters = new Button("Hide filter bar"); hideFilters.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { filterTable.setFiltersVisible(false); } }); buttonLayout.addComponent(hideFilters); return buttonLayout; } private Container buildContainer() { IndexedContainer cont = new IndexedContainer(); Calendar c = Calendar.getInstance(); cont.addContainerProperty("name", String.class, null); cont.addContainerProperty("id", Integer.class, null); cont.addContainerProperty("state", State.class, null); cont.addContainerProperty("date", Date.class, null); cont.addContainerProperty("validated", Boolean.class, null); Random random = new Random(); for (int i = 0; i < 10000; i++) { cont.addItem(i); /* Set name and id properties */ cont.getContainerProperty(i, "name").setValue("Order " + i); cont.getContainerProperty(i, "id").setValue(i); /* Set state property */ int rndInt = random.nextInt(4); State stateToSet = State.CREATED; if (rndInt == 0) { stateToSet = State.PROCESSING; } else if (rndInt == 1) { stateToSet = State.PROCESSED; } else if (rndInt == 2) { stateToSet = State.FINISHED; } cont.getContainerProperty(i, "state").setValue(stateToSet); /* Set date property */ cont.getContainerProperty(i, "date").setValue(c.getTime()); c.add(Calendar.DAY_OF_MONTH, 1); /* Set validated property */ cont.getContainerProperty(i, "validated").setValue( random.nextBoolean()); } return cont; } }
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
• Based on the Table of Vaadin 6.7.6 - some quite critical bugs were fixed there • Otherwise the same as v.0.5.1
- Released
- 2012-03-23
- Maturity
- BETA
- License
- Apache License 2.0
Compatibility
- Framework
- Vaadin 6.7+
- Vaadin 7.7+ in 0.9.16.v7
- Vaadin 8.0+ in 1.0.1.v8
- Vaadin 7.6+ in 0.9.15.v7
- Vaadin 7.3+ in 0.9.12.v7
- Vaadin 7.5+ in 0.9.13.v7
- Vaadin 7.1 in 0.9.8.v7
- Vaadin 7.0 in 0.8.9.v7
- Vaadin 6.8+ in 0.9.2
- Vaadin 6.0+ in 0.5.3
- Browser
- Internet Explorer
- Internet Explorer
- Firefox
- Opera
- Safari
- Google Chrome
- Internet Explorer
FilteringTable - Vaadin Add-on Directory
Extension of Vaadin Table, provides a filter bar below the table headerDiscussion Forum
Source Code
Online Demo (V7)
Issues in GitHub
FilteringTable version 0.5.0
null
FilteringTable version 0.5.1
• Fixed filter field width issue - should now work with virtually all themes
• Added support for text change events per property ID (thanks to Jean-François Lamy)
• Added method to adjust text change event timeout per property ID
• Removed the need to set the FilterDecorator before the container
• Added a getter for filter bar visibility state
• Added a resetFilters method
• Now preserves filter bar visibility state over container/decorator change and filter reset
FilteringTable version 0.5.2
• Based on the Table of Vaadin 6.7.6 - some quite critical bugs were fixed there
• Otherwise the same as v.0.5.1
FilteringTable version 0.5.3
Fixed broken JAR file inside the package (see https://vaadin.com/forum/-/message_boards/view_message/1168867#_19_message_1283164). Thanks Carlos!
FilteringTable version 0.6.0
* Based on Vaadin 6.8.2
* Added FilterGenerator.getCustomFilterComponent(Object propertyId) to enable customized filter components.
* Fixed handling of Object-typed property id:s.
* Removed getLocale() from FilterDecorator, now uses the application locale.
* Added a method in FilterDecorator to provide a caption to be shown in the filter components when no filter is defined.
* Fixed the FilterGenerator.generateFilter method to be called with a DateInterval when the filtered property is a date.
* Date filtering now uses Between, LessOrEqual and GreaterOrEqual filters in place of the custom filter.
* Fixed a bug when using Table.ROW_HEADER_MODE_INDEX.
* Allow hiding filters by returning a custom filter component with its visibility set to false.
* Added notifier methods to FilterGenerator so you can react to filters being removed/added to the datasource by the FilterTable.
* Added means to define both the DateField resolution and a custom formatter for the Date filters.
* Fixed issue with generated columns.
FilteringTable version 0.6.1
- Updated to Vaadin 6.8.3
- Refactoring and cleanup
- Added means to hide/show individual filter fields
- Should correctly handle generated columns
- Improved the demo application
FilteringTable version 0.7.0
* Debug info enabled.
* Fixed issue with missing horizontal scroll bar after toggling filter bar visibility.
* FilterFieldGenerator implements Serializable.
* Updated to Vaadin 6.8.4.
* Added number filtering popup by 'vimukthi', thank you!
FilteringTable version 0.7.1
* Upgraded to Vaadin 6.8.5.
* Added means to use the 'old' way for filtering numeric properties, instead of the popup filter (see FilterDecorator class).
* Fixed a reflection/autoboxing issue when using numeric popup filter with basic data types.
* Implemented Serializable for few classes where it was missing.
* Fixed two instances of Strings used as property IDs (thanks Tibi).
FilteringTable version 0.7.2
* Fixed minor CSS issues in popup filters
* Fixed NativeSelect not displaying properly in Chrome/IE
FilteringTable version 0.7.3
Added javadoc and a separate sources-jar.
FilteringTable version 0.8.0
Added preliminary support for a combination of PagedTable and FilteringTable.
FilteringTable version 0.8.2
* Added FilterTreeTable to use filtering with a TreeTable also
* Fixed a bug in filtering java.sql.Date and java.sql.Timestamp types
FilteringTable version 0.7.1.v7
Initial version of FilteringTable for Vaadin 7 RC.
Known issues:
* Filtering does not work in PagedTable or TreeTable
* PopupButton is not yet V7-compatible, so Date/Numeric popup filters are not available
* Focused filter field loses focus after a filter has been applied
Please try this out and report all issues in the Forum thread. Thanks!
FilteringTable version 0.8.3
* sources jar added to zip
* Fixed cursor position issue in IE (#11 in github)
* Replaced DateFormat with a String pattern in date filter formatting (#10)
FilteringTable version 0.8.4
* Updated base Table to Vaadin 6.8.9
* Made NumberInterval and DateInterval contructors public
* Removed setAlwaysRecalculateColumnWidths method since it was broken
* Added getLocale() method to FilterDecorator to allow reasonably set Date filter values before attaching the FilterTable to the application
FilteringTable version 0.8.0.v7
* Removed alwaysRecalculateColumnWidths since it's broken
* Fixed bug in generating dropdown for boolean type filtering
* Implemented DateFilterPopup and NumberFilterPopup for Vaadin 7 version
* Fixed style issue in filter TextFields
* DateFilterPopup in V7 version now uses InlineDateField components
FilteringTable version 0.8.1.v7
* Added pom.xml with dependency to PopupButton add-on. Should fix maven issues.
* Fixed a bug in hiding / showing individual filter fields
* Fixed a bug in the focusing of filter fields - should now work as expected
FilteringTable version 0.8.2.v7
* Base Table is now from Vaadin 7.0.2
* Fixed dynamic height issue which caused flickering in the PagedFilterTable
* Removed the non-functioning TreeTable classes
* Fixed a minor layout issue in PagedFilterTable
FilteringTable version 0.8.5
* Added pom.xml with PopupButton dependency for maven users
* Fixed a minor layout issue in PagedFilterTable
* Finally fixed the field focusing issues properly
FilteringTable version 0.8.3.v7
Fixed issue #16: Now removes/adds the related filter field into the filter bar when column is collapsed/uncollapsed.
Fixed issue #17: NPE when setting a column with Date/Numeric popup filter collapsed before attaching said popup.
Packaged into ZIP.
Added sources-jar, javadoc-jar, popupbutton dependency jar.
FilteringTable version 0.8.6
Fixed Issue #16: Collapsing a column now removes the corresponding Filter from the filter bar.
FilteringTable version 0.8.4.v7
Fixed issue #18 - Changing page in the paged filter table did not work at all.
FilteringTable version 0.8.7
* Added cleanup to build script
* Marked the remaining non-serializable classes and interfaces as serializable
* Prevent unnecessary events from paging controls in the Paged variety
* Fixed popup visibility state issues in date and numeric popup filters
* Now clicking the Clear button in date filter popup will clear the fields within the popup also
FilteringTable version 0.8.5.v7
* Fixes a number formatting issue in numeric popup filter
* Set the correct version number in the included pom.xml
* Note: Requires at least Vaadin 7.0.1
FilteringTable version 0.8.6.v7
* Fixes invalid connector hierarchy when setVisibleColumns is used to limit column visibility. This was not noticed before since it only seems to cause issues in IE8 (there's a client-side exception and the column alignment fails).
FilteringTable version 0.8.7.v7
* Another, hopefully better fix to the filter component connector hierarchy issue
* Removed forgotten debug output
FilteringTable version 0.8.8
Made PagedFilterTableContainer and PagedTableChangeEvent public to allow implementing custom controls for the PagedFilterTable.
FilteringTable version 0.8.8.v7
Made PagedFilterTableContainer and PagedTableChangeEvent public to allow implementing custom controls for the PagedFilterTable.
FilteringTable version 0.8.9
* Fixes exception when collapsing a column with numeric popup filter.
* Added a means to generate custom filter based on the Field (in the FilterGenerator interface).
* Fixes erroneous column alignment after filtering with a field that is outside the viewport (table needs to be horizontally scrolled to see the field).
* Fixes table body width being wrong when there are no results/rows.
* Added means to fetch individual filter component instances.
FilteringTable version 0.8.9.v7
* Fixes exception when collapsing a column with numeric popup filter.
* Added a means to generate custom filter based on the Field (in the FilterGenerator interface).
* Added means to fetch individual filter component instances.
FilteringTable version 0.9.0
* Uses 'Equal' filter for enums
* Added byte and short as numeric types (uses number filter popup)
FilteringTable version 0.9.0.v7
* Fixed a call to the wrong method in FilterGenerator
* Added a method to handle exceptions during filter generation
* Vaadin 7.1 support
* Updated underlying Table to Vaadin 7.1 version
* Now uses 'Equal' filtering for enums
* Added byte and short to numeric types (will use numeric filter popup)
FilteringTable version 0.9.1.v7
- Updated underlying Table code to Vaadin 7.1.6.
- Clears filter field value if generating the filter fails.
- #27: Disables popup filter buttons and fields when set to read only mode.
- #28: Now uses default date resolution if decorator returns null as the resolution.
- #29: Tooltips work again.
- #30: Fixed failing layout when ColumnHeaderMode.HIDDEN is used.
- #31: Fixed not being able to scroll to last row.
- #33: Now re-initializes filters when setVisibleColumns is called.
- #34: Now allows custom filter fields & filters for generated columns. Note: You must provide both the filter component and the filter yourself!
FilteringTable version 0.9.2.v7
Added support for TreeTable
FilteringTable version 0.9.1
- Upgraded the underlying Table to Vaadin 6.8.13
- Checks equality of new and old filter before removing/adding to prevent unneeded filtering
FilteringTable version 0.9.3.v7
- Upgraded the underlying Table to Vaadin 7.1.9
- Checks equality of new and old filter before removing/adding to prevent unneeded filtering
FilteringTable version 0.9.4.v7
- Call to setVisibleColumns no longer resets the filters and their properties
- Row indexes for Paged are now counted from the total size
- Removed reindeer-specific style selector (textfields)
- Fixed ClassCastException related to DnD
- Fixed Paged current page formatting issue
- Added locatization for Paged controls
- Fixed exception on clicking Clear in the filter popups
FilteringTable version 0.9.5.v7
* Upgraded to Vaadin 7.1.11
* Merged fix for random NPE (github issue #46)
* Paged: added check to ensure pageFirstIndex is not negative
* Paged: set enable/disable state of buttons properly on first render
* Paged: Introduced a class to allow changing all the captions and page lengths in the controls
FilteringTable version 0.9.6.v7
* Fixed filter field width calculation in cases where left/right margins are added to the fields via CSS.
FilteringTable version 0.9.2
* Fixes some imports preventing a successful build
* Fixed NPE in setting a new filter (github issue #49)
* Completed update to Vaadin 6.8.13
FilteringTable version 0.9.8.v7
* Added support for on-demand (lazy) filtering mode
* Added support for wrapper div elements around the filter fields
Please see the demo application for usage of both features!
FilteringTable version 0.9.9.v7
Now compatible with Vaadin 7.2.0.
Note: The changes made to Table in 7.2.0 have NOT been included in this version - this will be done later. This version is just a quick fix & release to enable using FilteringTable with Vaadin 7.2.0.
FilteringTable version 0.9.10.v7
Fixed a client-side exception when un-collapsing a column with the filter wrappers enabled.
FilteringTable version 0.9.11.v7
- Fixed issue #66: Filter field not shown using setContainerDataSource(Container, Collection)
- Provides a method to reset filter field values without rebuilding the fields: clearFilters()
- Updated underlying Table to Vaadin 7.3.2
- Fixed providing filters for generated columns
- Tested that filter fields are properly resized after re-showing filter bar if the columns have been resized while the bar was hidden
- Fixed issue #72: Cannot use FilteringTable with CDI due to invisible interface
- Added support to CustomTable.TableDropCriterion
- Fixed rendering with a hidden filter bar in IE8
- Tested table editable mode in IE8
- Tested and fixed compatibility with Valo and Runo themes
- Updated to PopupButton 2.4.1
- Added support for CustomTable.TableDropCriterion
FilteringTable version 0.9.12.v7
* Added support for custom style names in column headers
* Added support for BigDecimal and BigInteger
* Updated to PopupButton 2.5.0
Thanks for the external contributors for these patches!
FilteringTable version 0.9.13.v7
Quick fix for Vaadin 7.5.1 compatibility
FilteringTable version 0.9.14.v7
null
FilteringTable version 0.9.15.v7
Merged three external contributions:
https://github.com/tepi/FilteringTable/pull/88 - Fixes NPE during paint
https://github.com/tepi/FilteringTable/pull/97 - Optimize content refreshing
https://github.com/tepi/FilteringTable/pull/100 - Make DateFilterPopup extendable
FilteringTable version 1.0.0.v8
null
FilteringTable version 1.0.1.v8
Bunch of bug fixes
FilteringTable version 1.0.0.v7
Updated the copy-pasted Table code to Vaadin 7.7.10. Fixes at least https://github.com/tepi/FilteringTable/issues/126 and maybe some other issues as well.
FilteringTable version 1.0.1.v7
This version introduces a fix that will close the popup overlays of ComboBoxes and PopupButtons when the table has been scrolled horizontally. This is done to prevent misalignment of the popups as well as the popups overflowing the table component boundaries.
FilteringTable version 0.9.16.v7
Changes since 0.9.15.v7:
* Scrolling the table horizontally will now close any open filter popups