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

    Constructors
    Modifier
    Constructor
    Description
     
    Creates a new instance.
     
    EnhancedGrid(int pageSize)
     
    protected
    EnhancedGrid(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 generic DataProvider.
     
    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)
     
    protected
    EnhancedGrid(Class<T> beanType, B dataCommunicatorBuilder)
     
    protected
    EnhancedGrid(Class<T> beanType, B dataCommunicatorBuilder, boolean autoCreateColumns)
     
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    addColumn(com.vaadin.flow.data.renderer.Renderer<T> renderer)
     
    addColumn(com.vaadin.flow.function.ValueProvider<T,?> valueProvider)
     
    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)
     
    <V extends Comparable<? super V>>
    EnhancedColumn<T>
    addColumn(com.vaadin.flow.function.ValueProvider<T,V> valueProvider, String... sortingProperties)
     
    <V extends com.vaadin.flow.component.Component>
    EnhancedColumn<T>
    addComponentColumn(com.vaadin.flow.function.ValueProvider<T,V> componentProvider)
     
    com.vaadin.flow.shared.Registration
    addFilterClickedEventListener(com.vaadin.flow.component.ComponentEventListener<FilterClickedEvent<T>> listener)
    Add listener on filter-clicked event.
    protected boolean
    CancelEditConfirmDialog will be displayed if showCancelEditDialog is true and editor is in buffered mode.
    void
    Apply the filters selected for each column in FilterField
    protected void
    applyFilterPredicate(com.vaadin.flow.function.SerializablePredicate<T> finalPredicate)
    Apply filter predicate depending on the data provider
    void
    beforeLeave(com.vaadin.flow.router.BeforeLeaveEvent event)
     
    void
    Cancel the current item edition.
    protected void
    cancelEditItem(T newEditItem, com.vaadin.flow.router.BeforeLeaveEvent.ContinueNavigationAction action, com.vaadin.flow.function.SerializableRunnable onCancelCallback)
    Cancel the edition of the item.
    protected void
    cancelEditWithCancelCallback(com.vaadin.flow.function.SerializableRunnable onCancelCallback)
    Cancel the current item edition with an specific callback for cancel action.
    void
    Clear all selected filters and updates the displayed data.
    void
    editItem(T item)
    Edit the selected item.
     
    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.
    boolean
    isEditable(T item)
    Return whether an item is editable or not.
    void
    Called when the apply filter event is fired.
    protected void
    onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
     
    protected void
    onConfirmEditItem(T newEditItem)
    Confirm the edition of the item.
    protected void
    onConfirmEditItem(T newEditItem, com.vaadin.flow.router.BeforeLeaveEvent.ContinueNavigationAction action)
    Confirm the edition of the item.
    protected void
     
    void
    setEditablePredicate(com.vaadin.flow.function.SerializablePredicate<T> editablePredicate)
    Define if an item can be edited.
    void
    setFilterIcon(com.vaadin.flow.component.icon.Icon filterIcon)
    Sets an Icon to be use as the filter icon in the columns header.
    void
    setPartNameGenerator(com.vaadin.flow.function.SerializableFunction<T,String> partNameGenerator)
     
    com.vaadin.flow.component.grid.GridSelectionModel<T>
    setSelectionMode(com.vaadin.flow.component.grid.Grid.SelectionMode selectionMode)
     
    void
    setSelectionPredicate(com.vaadin.flow.function.SerializablePredicate<T> selectionPredicate)
    Disable selection/deselection of the item that doesn't match the selectionPredicate
    void
    setShowCancelEditDialog(boolean showCancelEditDialog)
    Set showCancelEditDialog value to know if CancelEditConfirmDialog should 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, refreshViewport, 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, updateSelectionModeOnClient

    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, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.BlurNotifier

    addBlurListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.Focusable

    addFocusShortcut, blur, focus, focus, getTabIndex, setTabIndex

    Methods inherited from interface com.vaadin.flow.component.FocusNotifier

    addFocusListener

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasEnabled

    isEnabled, setEnabled

    Methods inherited from interface com.vaadin.flow.data.provider.HasLazyDataView

    setItems, setItems

    Methods inherited from interface com.vaadin.flow.data.provider.HasListDataView

    setItems, setItems

    Methods 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, setWidthFull

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName

    Methods 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:
      • Grid()
    • EnhancedGrid

      public EnhancedGrid(com.vaadin.flow.data.provider.DataProvider<T,Void> dataProvider)
      Creates a new grid using the given generic DataProvider.
      Parameters:
      dataProvider - the data provider, not null
      See Also:
      • Grid(DataProvider)
    • EnhancedGrid

      public EnhancedGrid(com.vaadin.flow.data.provider.BackEndDataProvider<T,Void> dataProvider)
      Parameters:
      dataProvider - the data provider, not null
      See Also:
      • Grid(BackEndDataProvider)
    • EnhancedGrid

      public EnhancedGrid(com.vaadin.flow.data.provider.InMemoryDataProvider<T> inMemoryDataProvider)
      Parameters:
      inMemoryDataProvider - the data provider, not null
      See Also:
      • Grid(InMemoryDataProvider)
    • EnhancedGrid

      public EnhancedGrid(com.vaadin.flow.data.provider.ListDataProvider<T> dataProvider)
      Parameters:
      dataProvider - the data provider, not null
      See Also:
      • Grid(ListDataProvider)
    • EnhancedGrid

      public EnhancedGrid(Collection<T> items)
      Parameters:
      items - the collection of items, not null
      See Also:
      • Grid(Collection)
    • EnhancedGrid

      public EnhancedGrid(int pageSize)
      Parameters:
      pageSize - - the page size. Must be greater than zero.
      See Also:
      • Grid(int)
    • EnhancedGrid

      public EnhancedGrid(Class<T> beanType, boolean autoCreateColumns)
      Parameters:
      beanType - - the bean type to use, not null
      autoCreateColumns - – when true, columns are created automatically for the properties of the beanType
      See Also:
      • Grid(Class, boolean)
    • EnhancedGrid

      public EnhancedGrid(Class<T> beanType)
      Parameters:
      beanType - - the bean type to use, not null
      See Also:
      • Grid(Class)
    • EnhancedGrid

      protected EnhancedGrid(Class<T> beanType, B dataCommunicatorBuilder)
      Type Parameters:
      U - the GridArrayUpdater type
      B - the data communicator builder type
      Parameters:
      beanType - the bean type to use, not null
      dataCommunicatorBuilder - Builder for DataCommunicator implementation this Grid uses to handle all data communication.
      See Also:
      • Grid(Class, DataCommunicatorBuilder)
    • EnhancedGrid

      protected EnhancedGrid(Class<T> beanType, B dataCommunicatorBuilder, boolean autoCreateColumns)
      Type Parameters:
      U - the GridArrayUpdater type
      B - the data communicator builder type
      Parameters:
      beanType - the bean type to use, not null
      dataCommunicatorBuilder - Builder for DataCommunicator implementation this Grid uses to handle all data communication.
      autoCreateColumns - when true, columns are created automatically for the properties of the beanType
      See Also:
      • Grid(Class, DataCommunicatorBuilder, boolean)
    • EnhancedGrid

      protected EnhancedGrid(int pageSize, B dataCommunicatorBuilder)
      Type Parameters:
      U - the GridArrayUpdater type
      B - the data communicator builder type
      Parameters:
      pageSize - the page size. Must be greater than zero.
      dataCommunicatorBuilder - Builder for DataCommunicator implementation this Grid uses to handle all data communication.
      See Also:
      • Grid(int, DataCommunicatorBuilder)
  • Method Details

    • getSelectionPredicate

      public com.vaadin.flow.function.SerializablePredicate<T> 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:
      setPartNameGenerator in class com.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:
      setSelectionMode in class com.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

      public boolean isEditable(T item)
      Return whether an item is editable or not.
      Parameters:
      item - the item to test
      Returns:
      true if the item is editable, false otherwise
    • editItem

      public void editItem(T item)
      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
    • cancelEditItem

      protected void cancelEditItem(T newEditItem, com.vaadin.flow.router.BeforeLeaveEvent.ContinueNavigationAction action, com.vaadin.flow.function.SerializableRunnable onCancelCallback)
      Cancel the edition of the item.
      Parameters:
      newEditItem - the new item to edit
      action - the action to proceed
      onCancelCallback - the callback to execute on cancel action
    • onConfirmEditItem

      protected void onConfirmEditItem(T newEditItem)
      Confirm the edition of the item.
      Parameters:
      newEditItem - the new item to edit
    • onConfirmEditItem

      protected void onConfirmEditItem(T newEditItem, com.vaadin.flow.router.BeforeLeaveEvent.ContinueNavigationAction action)
      Confirm the edition of the item.
      Parameters:
      newEditItem - the new item to edit
      action - the action to proceed
    • setShowCancelEditDialog

      public void setShowCancelEditDialog(boolean showCancelEditDialog)
      Set showCancelEditDialog value to know if CancelEditConfirmDialog should be displayed.
      Parameters:
      showCancelEditDialog - the value to set
    • allowCancelEditDialogDisplay

      protected boolean allowCancelEditDialogDisplay()
      CancelEditConfirmDialog will be displayed if showCancelEditDialog is true and editor is in buffered mode.
      Returns:
      true if CancelEditConfirmDialog should be displayed
    • beforeLeave

      public void beforeLeave(com.vaadin.flow.router.BeforeLeaveEvent event)
      Specified by:
      beforeLeave in interface com.vaadin.flow.router.internal.BeforeLeaveHandler
    • getDefaultColumnFactory

      protected BiFunction<com.vaadin.flow.data.renderer.Renderer<T>,String,com.vaadin.flow.component.grid.Grid.Column<T>> getDefaultColumnFactory()
      Return the default column factory.
      Overrides:
      getDefaultColumnFactory in class com.vaadin.flow.component.grid.Grid<T>
      See Also:
      • Grid.getDefaultColumnFactory()
    • addColumn

      public EnhancedColumn<T> addColumn(com.vaadin.flow.function.ValueProvider<T,?> valueProvider)
      Overrides:
      addColumn in class com.vaadin.flow.component.grid.Grid<T>
      See Also:
      • Grid.addColumn(ValueProvider)
    • 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:
      addColumn in class com.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:
      addColumn in class com.vaadin.flow.component.grid.Grid<T>
      See Also:
      • Grid.addColumn(ValueProvider, String...)
    • addColumn

      public EnhancedColumn<T> addColumn(com.vaadin.flow.data.renderer.Renderer<T> renderer)
      Overrides:
      addColumn in class com.vaadin.flow.component.grid.Grid<T>
      See Also:
      • Grid.addColumn(Renderer)
    • addComponentColumn

      public <V extends com.vaadin.flow.component.Component> EnhancedColumn<T> addComponentColumn(com.vaadin.flow.function.ValueProvider<T,V> componentProvider)
      Overrides:
      addComponentColumn in class com.vaadin.flow.component.grid.Grid<T>
      See Also:
      • Grid.addComponentColumn(ValueProvider)
    • getColumnByKey

      public EnhancedColumn<T> getColumnByKey(String columnKey)
      Overrides:
      getColumnByKey in class com.vaadin.flow.component.grid.Grid<T>
      See Also:
      • Grid.getColumnByKey(String)
    • setColumnKey

      protected void setColumnKey(String key, EnhancedColumn<T> column)
    • onApplyFilter

      public void onApplyFilter(Object filter)
      Description copied from interface: ApplyFilterListener
      Called when the apply filter event is fired.
      Specified by:
      onApplyFilter in interface ApplyFilterListener
      Parameters:
      filter - the filter to apply
    • applyFilter

      public void applyFilter()
      Apply the filters selected for each column in FilterField
    • 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 an Icon to 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:
      onAttach in class com.vaadin.flow.component.grid.Grid<T>