Class AdvancedGrid<T>
java.lang.Object
com.vaadin.flow.component.Component
org.vaadin.addons.antlerflow.grid.AdvancedGrid<T>
- Type Parameters:
T- the type of items contained in the grid
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasComponents, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, Serializable
@Tag("af-advanced-grid")
@JsModule("./antlerflow/advanced-grid/advanced-grid.ts")
public class AdvancedGrid<T>
extends com.vaadin.flow.component.Component
implements com.vaadin.flow.component.HasComponents, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle
AdvancedGrid is a component that enhances the functionality of a standard Grid by incorporating
built-in pagination, data export capabilities, a column selector that remembers the user's
choice (in the browser, a database or any custom storage), and a customizable toolbar. It is designed to work with various data
providers and supports dynamic setting of data, page sizes, and pagination visibility.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringPrefix of the storage keys holding column preferences. -
Constructor Summary
ConstructorsConstructorDescriptionAdvancedGrid(int pageSize) AdvancedGrid(com.vaadin.flow.component.grid.Grid<T> grid) AdvancedGrid(com.vaadin.flow.data.provider.BackEndDataProvider<T, Void> dataProvider) AdvancedGrid(com.vaadin.flow.data.provider.DataProvider<T, Void> dataProvider) AdvancedGrid(com.vaadin.flow.data.provider.InMemoryDataProvider<T> inMemoryDataProvider) AdvancedGrid(com.vaadin.flow.data.provider.ListDataProvider<T> dataProvider) AdvancedGrid(Class<T> beanType) AdvancedGrid(Class<T> beanType, boolean autoCreateColumns) AdvancedGrid(Collection<T> items) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToActions(com.vaadin.flow.component.Component... components) Adds components to the toolbar's action area.voidaddToFilters(com.vaadin.flow.component.Component... components) Adds components to the "toolbar" slot.voidaddToFooter(com.vaadin.flow.component.Component... components) Adds components to the "footer" slot.voidRemoves the stored column preference from the storage.voidenableColumnSelection(boolean enabled) Shows or removes the column selector button.voidenableExport(boolean exportEnabled) Shows or removes the export button.Returns the full storage key, or empty while it cannot be derived yet.booleanReturnstruewhen there is something to export with the current configuration: the grid has rows, and forExportSize.SELECTEDat least one row is selected.protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) voidSets the storage key suffix under which the column preference is stored.voidsetColumnPreferencePersisted(boolean persisted) Turns storing the column preference on (default) or off.voidSets where the column preference is stored, e.g.voidsetDataProvider(com.vaadin.flow.data.provider.DataProvider<T, ?> dataProvider) voidsetExportConfig(GridExportConfig<T> exportConfig) voidsetInnerGrid(com.vaadin.flow.component.grid.Grid<T> innerGrid) Injects the given Grid into the "grid" slot inside the Lit template.voidvoidsetPageSize(int pageSize) voidsetPageSizes(Integer... pageSizes) voidsetPaginationVisibility(boolean visibility) Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasComponents
add, add, add, addComponentAsFirst, addComponentAtIndex, remove, remove, removeAllMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Field Details
-
COLUMN_PREFERENCE_KEY_PREFIX
Prefix of the storage keys holding column preferences.- See Also:
-
-
Constructor Details
-
AdvancedGrid
public AdvancedGrid() -
AdvancedGrid
-
AdvancedGrid
-
AdvancedGrid
-
AdvancedGrid
-
AdvancedGrid
-
AdvancedGrid
-
AdvancedGrid
public AdvancedGrid(int pageSize) -
AdvancedGrid
-
AdvancedGrid
-
-
Method Details
-
setInnerGrid
Injects the given Grid into the "grid" slot inside the Lit template. -
setItems
-
setDataProvider
-
setPageSizes
-
setPageSize
public void setPageSize(int pageSize) -
setExportConfig
-
enableExport
public void enableExport(boolean exportEnabled) Shows or removes the export button. The button is enabled only while the grid has data to export (and, forExportSize.SELECTED, while rows are selected). When rows are selected andis on, clicking it lets the user export either the configured rows or only the selected rows.invalid reference
GridExportConfig#isSelectedRowsOption() -
isExportAvailable
public boolean isExportAvailable()Returnstruewhen there is something to export with the current configuration: the grid has rows, and forExportSize.SELECTEDat least one row is selected. -
enableColumnSelection
public void enableColumnSelection(boolean enabled) Shows or removes the column selector button. The user's choice of displayed columns is kept in thecolumn preference storage(the browser'slocalStorageby default) undergetColumnPreferenceStorageKey()and restored whenever the grid is attached. -
setColumnPreferenceKey
Sets the storage key suffix under which the column preference is stored. Give each grid its own key when a view holds several grids. When not set, the component id is used, or else the current route path. -
getColumnPreferenceStorageKey
-
setColumnPreferenceStorage
Sets where the column preference is stored, e.g.ColumnPreferenceStorage.sessionStorage()or aJdbcColumnPreferenceStorage. The preference is loaded from the new storage right away when the grid is attached. -
setColumnPreferencePersisted
public void setColumnPreferencePersisted(boolean persisted) Turns storing the column preference on (default) or off. Turning it off does not delete an already stored preference; useclearColumnPreference()for that. -
clearColumnPreference
public void clearColumnPreference()Removes the stored column preference from the storage. -
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
setPaginationVisibility
public void setPaginationVisibility(boolean visibility) -
addToFilters
public void addToFilters(com.vaadin.flow.component.Component... components) Adds components to the "toolbar" slot. -
addToActions
public void addToActions(com.vaadin.flow.component.Component... components) Adds components to the toolbar's action area. Buttons get the tertiary theme variant so actions stay quiet next to the grid; remove it withbutton.removeThemeVariants(ButtonVariant.LUMO_TERTIARY)when an action must stand out.
-