Class EnhancedGrid<T>
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.grid.Grid<T>
com.vaadin.componentfactory.enhancedgrid.EnhancedGrid<T>
- Type Parameters:
T- the grid bean type
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.grid.Grid<T>>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.Focusable<com.vaadin.flow.component.grid.Grid<T>>,com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.grid.Grid<T>>,ApplyFilterListener,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasTheme,com.vaadin.flow.data.event.SortEvent.SortNotifier<com.vaadin.flow.component.grid.Grid<T>,,com.vaadin.flow.component.grid.GridSortOrder<T>> com.vaadin.flow.data.provider.HasDataGenerators<T>,com.vaadin.flow.data.provider.HasDataView<T,,Void, com.vaadin.flow.component.grid.dataview.GridDataView<T>> com.vaadin.flow.data.provider.HasLazyDataView<T,,Void, com.vaadin.flow.component.grid.dataview.GridLazyDataView<T>> com.vaadin.flow.data.provider.HasListDataView<T,,com.vaadin.flow.component.grid.dataview.GridListDataView<T>> com.vaadin.flow.router.BeforeLeaveObserver,com.vaadin.flow.router.internal.BeforeLeaveHandler,Serializable
- Direct Known Subclasses:
EnhancedTreeGrid
@CssImport(value="./styles/enhanced-grid-selection-disabled.css",
themeFor="vaadin-grid")
public class EnhancedGrid<T>
extends com.vaadin.flow.component.grid.Grid<T>
implements com.vaadin.flow.router.BeforeLeaveObserver, ApplyFilterListener
Add a selectionPredicate to forbid the grid selection for specific rows
Add a editablePredicate to forbid the edition for specific rows
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.grid.Grid
com.vaadin.flow.component.grid.Grid.AbstractGridExtension<T>, com.vaadin.flow.component.grid.Grid.Column<T>, com.vaadin.flow.component.grid.Grid.DataCommunicatorBuilder<T,U extends com.vaadin.flow.data.provider.ArrayUpdater>, com.vaadin.flow.component.grid.Grid.MultiSortPriority, com.vaadin.flow.component.grid.Grid.NestedNullBehavior, com.vaadin.flow.component.grid.Grid.SelectionMode, com.vaadin.flow.component.grid.Grid.SpringData, com.vaadin.flow.component.grid.Grid.UpdateQueue Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component> -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates a new instance.EnhancedGrid(int pageSize) protectedEnhancedGrid(int pageSize, B dataCommunicatorBuilder) EnhancedGrid(com.vaadin.flow.data.provider.BackEndDataProvider<T, Void> dataProvider) EnhancedGrid(com.vaadin.flow.data.provider.DataProvider<T, Void> dataProvider) Creates a new grid using the given genericDataProvider.EnhancedGrid(com.vaadin.flow.data.provider.InMemoryDataProvider<T> inMemoryDataProvider) EnhancedGrid(com.vaadin.flow.data.provider.ListDataProvider<T> dataProvider) EnhancedGrid(Class<T> beanType) EnhancedGrid(Class<T> beanType, boolean autoCreateColumns) protectedEnhancedGrid(Class<T> beanType, B dataCommunicatorBuilder) protectedEnhancedGrid(Class<T> beanType, B dataCommunicatorBuilder, boolean autoCreateColumns) EnhancedGrid(Collection<T> items) -
Method Summary
Modifier and TypeMethodDescriptionprotected <C extends com.vaadin.flow.component.grid.Grid.Column<T>>
CaddColumn(com.vaadin.flow.function.ValueProvider<T, ?> valueProvider, BiFunction<com.vaadin.flow.data.renderer.Renderer<T>, String, C> columnFactory) <V extends Comparable<? super V>>
EnhancedColumn<T> <V extends com.vaadin.flow.component.Component>
EnhancedColumn<T> addComponentColumn(com.vaadin.flow.function.ValueProvider<T, V> componentProvider) com.vaadin.flow.shared.RegistrationaddFilterClickedEventListener(com.vaadin.flow.component.ComponentEventListener<FilterClickedEvent<T>> listener) Add listener on filter-clicked event.protected booleanCancelEditConfirmDialogwill be displayed if showCancelEditDialog is true and editor is in buffered mode.voidApply the filters selected for each column inFilterFieldprotected voidapplyFilterPredicate(com.vaadin.flow.function.SerializablePredicate<T> finalPredicate) Apply filter predicate depending on the data providervoidbeforeLeave(com.vaadin.flow.router.BeforeLeaveEvent event) voidCancel the current item edition.protected voidcancelEditItem(T newEditItem, com.vaadin.flow.router.BeforeLeaveEvent.ContinueNavigationAction action, com.vaadin.flow.function.SerializableRunnable onCancelCallback) Cancel the edition of the item.protected voidcancelEditWithCancelCallback(com.vaadin.flow.function.SerializableRunnable onCancelCallback) Cancel the current item edition with an specific callback for cancel action.voidClear all selected filters and updates the displayed data.voidEdit the selected item.getColumnByKey(String columnKey) protected BiFunction<com.vaadin.flow.data.renderer.Renderer<T>, String, com.vaadin.flow.component.grid.Grid.Column<T>> Return the default column factory.com.vaadin.flow.function.SerializablePredicate<T> Define if an item can be selected.booleanisEditable(T item) Return whether an item is editable or not.voidonApplyFilter(Object filter) Called when the apply filter event is fired.protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) protected voidonConfirmEditItem(T newEditItem) Confirm the edition of the item.protected voidonConfirmEditItem(T newEditItem, com.vaadin.flow.router.BeforeLeaveEvent.ContinueNavigationAction action) Confirm the edition of the item.protected voidsetColumnKey(String key, EnhancedColumn<T> column) voidsetEditablePredicate(com.vaadin.flow.function.SerializablePredicate<T> editablePredicate) Define if an item can be edited.voidsetFilterIcon(com.vaadin.flow.component.icon.Icon filterIcon) Sets anIconto be use as the filter icon in the columns header.voidsetPartNameGenerator(com.vaadin.flow.function.SerializableFunction<T, String> partNameGenerator) com.vaadin.flow.component.grid.GridSelectionModel<T> setSelectionMode(com.vaadin.flow.component.grid.Grid.SelectionMode selectionMode) voidsetSelectionPredicate(com.vaadin.flow.function.SerializablePredicate<T> selectionPredicate) Disable selection/deselection of the item that doesn't match the selectionPredicatevoidsetShowCancelEditDialog(boolean showCancelEditDialog) Set showCancelEditDialog value to know ifCancelEditConfirmDialogshould be displayed.Methods inherited from class com.vaadin.flow.component.grid.Grid
addCellFocusListener, addColumn, addColumn, addColumn, addColumnReorderListener, addColumnResizeListener, addColumns, addContextMenu, addDataGenerator, addDragEndListener, addDragStartListener, addDropListener, addFirstHeaderRow, addItemClickListener, addItemDoubleClickListener, addSelectionListener, addSortListener, addThemeVariants, addValueProvider, appendFooterRow, appendHeaderRow, asMultiSelect, asSingleSelect, compareMaybeComparables, configureBeanType, createColumn, createColumnId, createDefaultArrayUpdater, createEditor, createSortingComparator, deselect, deselectAll, getAriaLabel, getArrayUpdater, getBeanType, getColumnByInternalId, getColumnLayers, getColumnRendering, getColumns, getDataCommunicator, getDataProvider, getDefaultHeaderRow, getDragFilter, getDropFilter, getDropMode, getEditor, getEmptyStateComponent, getEmptyStateText, getFooterRows, getGenericDataView, getHeaderRows, getLazyDataView, getListDataView, getNestedNullBehavior, getPageSize, getPartNameGenerator, getPropertySet, getSelectedItems, getSelectionMode, getSelectionModel, getSelectionPreservationMode, getSortOrder, getTooltipPosition, getUniqueKeyProperty, getUniqueKeyProvider, initConnector, insertColumnLayer, isAllRowsVisible, isColumnReorderingAllowed, isDetailsVisible, isDetailsVisibleOnClick, isMultiSort, isRowsDraggable, isTooltipMarkdownEnabled, onDataProviderChange, onDetach, onEnabledStateChanged, prependFooterRow, prependHeaderRow, recalculateColumnWidths, removeAllColumns, removeAllFooterRows, removeAllHeaderRows, removeColumn, removeColumnByKey, removeColumnLayer, removeColumns, removeFooterRow, removeHeaderRow, removeThemeVariants, scrollToEnd, scrollToIndex, scrollToItem, scrollToStart, select, setAllRowsVisible, setAriaLabel, setColumnKey, setColumnOrder, setColumnOrder, setColumnRendering, setColumnReorderingAllowed, setColumns, setDataProvider, setDefaultMultiSortPriority, setDetailsVisible, setDetailsVisibleOnClick, setDragDataGenerator, setDragFilter, setDropFilter, setDropMode, setEmptyStateComponent, setEmptyStateText, setItemDetailsRenderer, setItems, setItems, setItems, setItems, setItemSelectableProvider, setItemsPageable, setItemsPageable, setMultiSort, setMultiSort, setMultiSort, setMultiSort, setNestedNullBehavior, setPageSize, setRowsDraggable, setSelectionDragDetails, setSelectionModel, setSelectionPreservationMode, setSortableColumns, setTooltipGenerator, setTooltipMarkdownEnabled, setTooltipPosition, setUniqueKeyProperty, setUniqueKeyProvider, sort, updateSelectionModeOnClientMethods 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, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.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.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods 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.data.provider.HasLazyDataView
setItems, setItemsMethods inherited from interface com.vaadin.flow.data.provider.HasListDataView
setItems, setItemsMethods 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, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
-
Constructor Details
-
EnhancedGrid
public EnhancedGrid()Creates a new instance.- See Also:
-
EnhancedGrid
Creates a new grid using the given genericDataProvider.- Parameters:
dataProvider- the data provider, notnull- See Also:
-
EnhancedGrid
- Parameters:
dataProvider- the data provider, notnull- See Also:
-
EnhancedGrid
- Parameters:
inMemoryDataProvider- the data provider, notnull- See Also:
-
EnhancedGrid
- Parameters:
dataProvider- the data provider, notnull- See Also:
-
EnhancedGrid
- Parameters:
items- the collection of items, notnull- See Also:
-
EnhancedGrid
public EnhancedGrid(int pageSize) - Parameters:
pageSize- - the page size. Must be greater than zero.- See Also:
-
EnhancedGrid
- Parameters:
beanType- - the bean type to use, not nullautoCreateColumns- – when true, columns are created automatically for the properties of the beanType- See Also:
-
EnhancedGrid
- Parameters:
beanType- - the bean type to use, not null- See Also:
-
EnhancedGrid
- Type Parameters:
U- the GridArrayUpdater typeB- the data communicator builder type- Parameters:
beanType- the bean type to use, notnulldataCommunicatorBuilder- Builder forDataCommunicatorimplementation this Grid uses to handle all data communication.- See Also:
-
EnhancedGrid
- Type Parameters:
U- the GridArrayUpdater typeB- the data communicator builder type- Parameters:
beanType- the bean type to use, notnulldataCommunicatorBuilder- Builder forDataCommunicatorimplementation this Grid uses to handle all data communication.autoCreateColumns- whentrue, columns are created automatically for the properties of the beanType- See Also:
-
EnhancedGrid
protected EnhancedGrid(int pageSize, B dataCommunicatorBuilder) - Type Parameters:
U- the GridArrayUpdater typeB- the data communicator builder type- Parameters:
pageSize- the page size. Must be greater than zero.dataCommunicatorBuilder- Builder forDataCommunicatorimplementation this Grid uses to handle all data communication.- See Also:
-
-
Method Details
-
getSelectionPredicate
Define if an item can be selected.- Returns:
- the selectionPredicate
-
setSelectionPredicate
public void setSelectionPredicate(com.vaadin.flow.function.SerializablePredicate<T> selectionPredicate) Disable selection/deselection of the item that doesn't match the selectionPredicate- Parameters:
selectionPredicate- selectionPredicate
-
setPartNameGenerator
public void setPartNameGenerator(com.vaadin.flow.function.SerializableFunction<T, String> partNameGenerator) - Overrides:
setPartNameGeneratorin classcom.vaadin.flow.component.grid.Grid<T>
-
setSelectionMode
public com.vaadin.flow.component.grid.GridSelectionModel<T> setSelectionMode(com.vaadin.flow.component.grid.Grid.SelectionMode selectionMode) - Overrides:
setSelectionModein classcom.vaadin.flow.component.grid.Grid<T>
-
setEditablePredicate
public void setEditablePredicate(com.vaadin.flow.function.SerializablePredicate<T> editablePredicate) Define if an item can be edited.- Parameters:
editablePredicate- the editablePredicate to set
-
isEditable
Return whether an item is editable or not.- Parameters:
item- the item to test- Returns:
- true if the item is editable, false otherwise
-
editItem
Edit the selected item.- Parameters:
item- the item to edit
-
cancelEdit
public void cancelEdit()Cancel the current item edition. -
cancelEditWithCancelCallback
protected void cancelEditWithCancelCallback(com.vaadin.flow.function.SerializableRunnable onCancelCallback) Cancel the current item edition with an specific callback for cancel action.- Parameters:
onCancelCallback- the callback to execute when canceling the edition
-
onConfirmEditItem
Confirm the edition of the item.- Parameters:
newEditItem- the new item to edit
-
setShowCancelEditDialog
public void setShowCancelEditDialog(boolean showCancelEditDialog) Set showCancelEditDialog value to know ifCancelEditConfirmDialogshould be displayed.- Parameters:
showCancelEditDialog- the value to set
-
allowCancelEditDialogDisplay
protected boolean allowCancelEditDialogDisplay()CancelEditConfirmDialogwill be displayed if showCancelEditDialog is true and editor is in buffered mode.- Returns:
- true if
CancelEditConfirmDialogshould be displayed
-
beforeLeave
public void beforeLeave(com.vaadin.flow.router.BeforeLeaveEvent event) - Specified by:
beforeLeavein interfacecom.vaadin.flow.router.internal.BeforeLeaveHandler
-
getDefaultColumnFactory
protected BiFunction<com.vaadin.flow.data.renderer.Renderer<T>,String, getDefaultColumnFactory()com.vaadin.flow.component.grid.Grid.Column<T>> Return the default column factory.- Overrides:
getDefaultColumnFactoryin classcom.vaadin.flow.component.grid.Grid<T>- See Also:
-
addColumn
- Overrides:
addColumnin classcom.vaadin.flow.component.grid.Grid<T>- See Also:
-
addColumn
protected <C extends com.vaadin.flow.component.grid.Grid.Column<T>> C addColumn(com.vaadin.flow.function.ValueProvider<T, ?> valueProvider, BiFunction<com.vaadin.flow.data.renderer.Renderer<T>, String, C> columnFactory) - Overrides:
addColumnin classcom.vaadin.flow.component.grid.Grid<T>
-
addColumn
public <V extends Comparable<? super V>> EnhancedColumn<T> addColumn(com.vaadin.flow.function.ValueProvider<T, V> valueProvider, String... sortingProperties) - Overrides:
addColumnin classcom.vaadin.flow.component.grid.Grid<T>- See Also:
-
addColumn
- Overrides:
addColumnin classcom.vaadin.flow.component.grid.Grid<T>- See Also:
-
addComponentColumn
public <V extends com.vaadin.flow.component.Component> EnhancedColumn<T> addComponentColumn(com.vaadin.flow.function.ValueProvider<T, V> componentProvider) - Overrides:
addComponentColumnin classcom.vaadin.flow.component.grid.Grid<T>- See Also:
-
getColumnByKey
- Overrides:
getColumnByKeyin classcom.vaadin.flow.component.grid.Grid<T>- See Also:
-
setColumnKey
-
onApplyFilter
Description copied from interface:ApplyFilterListenerCalled when the apply filter event is fired.- Specified by:
onApplyFilterin interfaceApplyFilterListener- Parameters:
filter- the filter to apply
-
applyFilter
public void applyFilter()Apply the filters selected for each column inFilterField -
applyFilterPredicate
protected void applyFilterPredicate(com.vaadin.flow.function.SerializablePredicate<T> finalPredicate) Apply filter predicate depending on the data provider- Parameters:
finalPredicate-
-
clearAllFilters
public void clearAllFilters()Clear all selected filters and updates the displayed data. -
addFilterClickedEventListener
public com.vaadin.flow.shared.Registration addFilterClickedEventListener(com.vaadin.flow.component.ComponentEventListener<FilterClickedEvent<T>> listener) Add listener on filter-clicked event.- Parameters:
listener-- Returns:
- registration which can remove the listener.
-
setFilterIcon
public void setFilterIcon(com.vaadin.flow.component.icon.Icon filterIcon) Sets anIconto be use as the filter icon in the columns header. If not icon is specified it will display VaadinIcon.FILTER icon as default.- Parameters:
filterIcon- the icon to display as filter icon
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.grid.Grid<T>
-