Class SpreadsheetFilterTable
- All Implemented Interfaces:
Serializable
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringprotected org.apache.poi.ss.util.CellRangeAddressprotected final Map<PopupButton,com.vaadin.flow.component.button.Button> protected final Map<PopupButton,HashSet<SpreadsheetFilter>> Fields inherited from class com.vaadin.flow.component.spreadsheet.SpreadsheetTable
popupButtons -
Constructor Summary
ConstructorsConstructorDescriptionSpreadsheetFilterTable(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.usermodel.Sheet sheet, org.apache.poi.ss.util.CellRangeAddress fullTableRegion, org.openxmlformats.schemas.spreadsheetml.x2006.main.CTAutoFilter ctWorksheetAutoFilter, org.apache.poi.xssf.usermodel.XSSFTable xssfTable) 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
Modifier and TypeMethodDescriptionvoidclear()Clears all the pop-up buttons and their contents (filters).voidClears all filters for this table.protected com.vaadin.flow.component.button.ButtonCreates a "Clear filters" button.org.apache.poi.ss.util.CellRangeAddressGets the filtering region,CellRangeAddressfor this table.protected voidCreates the "Clear filters" buttons for the pop-ups.protected voidCreates all filters for this table.protected voidCreates item filters for this table.voidCalled 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 Details
-
CLEAR_FILTERS_BUTTON_CLASSNAME
- See Also:
-
FILTER_TABLE_CONTENT_CLASSNAME
- See Also:
-
popupButtonToFiltersMap
-
popupButtonToClearButtonMap
protected final Map<PopupButton,com.vaadin.flow.component.button.Button> popupButtonToClearButtonMap -
filteringRegion
protected org.apache.poi.ss.util.CellRangeAddress filteringRegion
-
-
Constructor Details
-
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
-
SpreadsheetFilterTable
public SpreadsheetFilterTable(Spreadsheet spreadsheet, org.apache.poi.ss.usermodel.Sheet sheet, org.apache.poi.ss.util.CellRangeAddress fullTableRegion, org.openxmlformats.schemas.spreadsheetml.x2006.main.CTAutoFilter ctWorksheetAutoFilter, org.apache.poi.xssf.usermodel.XSSFTable xssfTable)
-
-
Method Details
-
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 com.vaadin.flow.component.button.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
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
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
-