Class SpreadsheetFilterTable
- java.lang.Object
-
- com.vaadin.flow.component.spreadsheet.SpreadsheetTable
-
- com.vaadin.flow.component.spreadsheet.SpreadsheetFilterTable
-
- All Implemented Interfaces:
Serializable
public class SpreadsheetFilterTable extends SpreadsheetTable
Represents a "table" inside a spreadsheet, that has filters (SpreadsheetFilter) inside the table's headers' pop-up buttons.Does simple filtering by hiding the filtered rows from the table (as in Excel).
Automatically generates "item filters" (
ItemFilter) for each column.Has a "Clear Filters" button inside the
PopupButtons pop-up, that clears all the filters for that column (contained within the same pop-up).- Author:
- Vaadin Ltd.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringCLEAR_FILTERS_BUTTON_CLASSNAMEstatic StringFILTER_TABLE_CONTENT_CLASSNAMEprotected org.apache.poi.ss.util.CellRangeAddressfilteringRegionprotected Map<PopupButton,Button>popupButtonToClearButtonMapprotected Map<PopupButton,HashSet<SpreadsheetFilter>>popupButtonToFiltersMap-
Fields inherited from class com.vaadin.flow.component.spreadsheet.SpreadsheetTable
popupButtons
-
-
Constructor Summary
Constructors Constructor Description SpreadsheetFilterTable(Spreadsheet spreadsheet, org.apache.poi.ss.usermodel.Sheet sheet, org.apache.poi.ss.util.CellRangeAddress fullTableRegion)Creates a new filter table for the given spreadsheet component, sheet and region.SpreadsheetFilterTable(Spreadsheet spreadsheet, org.apache.poi.ss.util.CellRangeAddress fullTableRegion)Creates a new filter table for the given spreadsheet component, its active sheet (Spreadsheet.getActiveSheet()and region.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears all the pop-up buttons and their contents (filters).voidclearAllFilters()Clears all filters for this table.protected ButtoncreateClearButton()Creates a "Clear filters" button.org.apache.poi.ss.util.CellRangeAddressgetFilteringRegion()Gets the filtering region,CellRangeAddressfor this table.protected voidinitClearAllButtons()Creates the "Clear filters" buttons for the pop-ups.protected voidinitFilters()Creates all filters for this table.protected voidinitItemFilters()Creates item filters for this table.voidonFiltersUpdated()Called when one of the filters (SpreadsheetFilter) has been updated, and the sheet (SpreadsheetTable.getSheet()) and component (SpreadsheetTable.getSpreadsheet()) need to be updated to reflect to the filters' values.voidregisterFilter(PopupButton popupButton, SpreadsheetFilter filter)Registers a new filter to this filter table and adds it inside the given pop-up button.voidreload()Reloads all the pop-up buttons and the pop-up contents (filters).voidunRegisterFilter(PopupButton popupButton, SpreadsheetFilter filter)Unregisters the filter from this filter table and removes it from the given pop-up button.-
Methods inherited from class com.vaadin.flow.component.spreadsheet.SpreadsheetTable
getCtWorksheetAutoFilter, getFullTableRegion, getPopupButton, getPopupButton, getPopupButtons, getSheet, getSpreadsheet, getXssfTable, initPopupButtons, isTableSheetCurrentlyActive, setCtWorksheetAutoFilter, setXssfTable
-
-
-
-
Field Detail
-
CLEAR_FILTERS_BUTTON_CLASSNAME
public static final String CLEAR_FILTERS_BUTTON_CLASSNAME
- See Also:
- Constant Field Values
-
FILTER_TABLE_CONTENT_CLASSNAME
public static final String FILTER_TABLE_CONTENT_CLASSNAME
- See Also:
- Constant Field Values
-
popupButtonToFiltersMap
protected final Map<PopupButton,HashSet<SpreadsheetFilter>> popupButtonToFiltersMap
-
popupButtonToClearButtonMap
protected final Map<PopupButton,Button> popupButtonToClearButtonMap
-
filteringRegion
protected org.apache.poi.ss.util.CellRangeAddress filteringRegion
-
-
Constructor Detail
-
SpreadsheetFilterTable
public SpreadsheetFilterTable(Spreadsheet spreadsheet, org.apache.poi.ss.util.CellRangeAddress fullTableRegion)
Creates a new filter table for the given spreadsheet component, its active sheet (Spreadsheet.getActiveSheet()and region. Pop-up buttons and content (filters) are created.- Parameters:
spreadsheet- Target SpreadsheetfullTableRegion- Cell range to include in the table
-
SpreadsheetFilterTable
public SpreadsheetFilterTable(Spreadsheet spreadsheet, org.apache.poi.ss.usermodel.Sheet sheet, org.apache.poi.ss.util.CellRangeAddress fullTableRegion)
Creates a new filter table for the given spreadsheet component, sheet and region. If the component is currently displaying the sheet that the table belongs to, pop-up buttons and content (filters) are created.- Parameters:
spreadsheet- Target Spreadsheetsheet- Target sheet within the SpreadsheetfullTableRegion- Cell range to include in the table
-
-
Method Detail
-
reload
public void reload()
Reloads all the pop-up buttons and the pop-up contents (filters).If the pop-up buttons and filters have been cleared (
clear()has been called) they will be recreated with "empty" filters. Otherwise the existing pop-up buttons are just added to the component again.- Overrides:
reloadin classSpreadsheetTable
-
clear
public void clear()
Clears all the pop-up buttons and their contents (filters).If this Table is reloaded after this method has been called, the filters will have cleared their states.
- Overrides:
clearin classSpreadsheetTable
-
clearAllFilters
public void clearAllFilters()
Clears all filters for this table. Does not remove the actual filter components.
-
initClearAllButtons
protected void initClearAllButtons()
Creates the "Clear filters" buttons for the pop-ups.
-
initFilters
protected void initFilters()
Creates all filters for this table. Override this in an extending class for adding filters on class construction.
-
initItemFilters
protected void initItemFilters()
Creates item filters for this table.
-
createClearButton
protected Button createClearButton()
Creates a "Clear filters" button. It has the "clear-filters-button" class name.- Returns:
- Button for clearing the filters
-
getFilteringRegion
public org.apache.poi.ss.util.CellRangeAddress getFilteringRegion()
Gets the filtering region,CellRangeAddressfor this table.- Returns:
- The filtering region
-
onFiltersUpdated
public void onFiltersUpdated()
Called when one of the filters (SpreadsheetFilter) has been updated, and the sheet (SpreadsheetTable.getSheet()) and component (SpreadsheetTable.getSpreadsheet()) need to be updated to reflect to the filters' values.NOTE: The default ItemFilters will call this method automatically on change. You only need to call this method when you have implemented and added your own SpreadsheetFilter.
-
registerFilter
public void registerFilter(PopupButton popupButton, SpreadsheetFilter filter)
Registers a new filter to this filter table and adds it inside the given pop-up button.NOTE: Does not apply updates, if the registered filter is filtering some rows,
onFiltersUpdated()should be called.- Parameters:
popupButton- The pop-up button this filter is added tofilter- The filter to apply
-
unRegisterFilter
public void unRegisterFilter(PopupButton popupButton, SpreadsheetFilter filter)
Unregisters the filter from this filter table and removes it from the given pop-up button.- Parameters:
popupButton- The pop-up button this filter is removed fromfilter- The filter to remove
-
-