Class EnhancedTreeGrid<T>

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.grid.Grid<T>
com.vaadin.componentfactory.enhancedgrid.EnhancedGrid<T>
com.vaadin.componentfactory.enhancedtreegrid.EnhancedTreeGrid<T>
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.data.provider.hierarchy.HasHierarchicalDataProvider<T>, com.vaadin.flow.router.BeforeLeaveObserver, com.vaadin.flow.router.internal.BeforeLeaveHandler, Serializable

@Uses(com.vaadin.flow.component.treegrid.TreeGrid.class) public class EnhancedTreeGrid<T> extends EnhancedGrid<T> implements com.vaadin.flow.data.provider.hierarchy.HasHierarchicalDataProvider<T>
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
     
     
    protected
    EnhancedTreeGrid(int pageSize, com.vaadin.flow.component.grid.Grid.DataCommunicatorBuilder<T,com.vaadin.flow.component.grid.GridArrayUpdater> dataCommunicatorBuilder)
     
     
    EnhancedTreeGrid(com.vaadin.flow.data.provider.hierarchy.HierarchicalDataProvider<T,?> dataProvider)
     
     
     
     
    EnhancedTreeGrid(Class<T> beanType, boolean autoCreateColumns)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.vaadin.flow.shared.Registration
    addCollapseListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.treegrid.CollapseEvent<T,EnhancedTreeGrid<T>>> listener)
    Adds a CollapseEvent listener to this EnhancedTreeGrid.
    <V extends com.vaadin.flow.component.Component>
    EnhancedColumn<T>
    addComponentHierarchyColumn(com.vaadin.flow.function.ValueProvider<T,V> componentProvider)
    Adds a new Hierarchy column that shows components.
    com.vaadin.flow.shared.Registration
    addExpandListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.treegrid.ExpandEvent<T,EnhancedTreeGrid<T>>> listener)
    Adds an ExpandEvent listener to this EnhancedTreeGrid.
    addHierarchyColumn(com.vaadin.flow.function.ValueProvider<T,?> valueProvider)
    Adds a new Hierarchy column to this Grid with a value provider.
    protected void
    applyFilterPredicate(com.vaadin.flow.function.SerializablePredicate<T> finalPredicate)
    Apply filter predicate depending on the data provider
    void
    Collapse the given items.
    protected void
    collapse(Collection<T> items, boolean userOriginated)
    Collapse the given items.
    void
    collapse(T... items)
    Collapse the given items.
    void
    collapseRecursively(Collection<T> items, int depth)
    Collapse the given items and their children recursively until the given depth.
    void
    collapseRecursively(Stream<T> items, int depth)
    Collapse the given items and their children recursively until the given depth.
    void
    Expands the given items.
    protected void
    expand(Collection<T> items, boolean userOriginated)
    Expands the given items.
    void
    expand(T... items)
    Expands the given items.
    void
    expandRecursively(Collection<T> items, int depth)
    Expands the given items and their children recursively until the given depth.
    void
    expandRecursively(Stream<T> items, int depth)
    Expands the given items and their children recursively until the given depth.
    com.vaadin.flow.data.provider.hierarchy.HierarchicalDataCommunicator<T>
     
    com.vaadin.flow.data.provider.hierarchy.HierarchicalDataProvider<T,com.vaadin.flow.function.SerializablePredicate<T>>
     
    com.vaadin.flow.component.grid.dataview.GridDataView<T>
    Deprecated.
    not supported
    protected Collection<T>
    Gets given items and their children recursively until the given depth.
    com.vaadin.flow.component.grid.dataview.GridLazyDataView<T>
    Deprecated.
    not supported
    com.vaadin.flow.component.grid.dataview.GridListDataView<T>
    Deprecated.
    not supported
    boolean
    isExpanded(T item)
    Returns whether a given item is expanded or collapsed.
    void
     
    void
    scrollToIndex(int index)
    Scrolls to the index of an item so that the row is shown at the start of the visible area whenever possible.
    void
    scrollToIndex(int... path)
    Scrolls to a nested item specified by its hierarchical path.
    void
     
    com.vaadin.flow.component.grid.Grid.Column<T>
    setColumns(String hierarchyPropertyName, com.vaadin.flow.function.ValueProvider<T,?> valueProvider, Collection<String> propertyNames)
    Note: This method can only be used for a TreeGrid created from a bean type with EnhancedTreeGrid(Class).
    void
    setDataProvider(com.vaadin.flow.data.provider.DataProvider<T,?> dataProvider)
    Deprecated.
    use setDataProvider(HierarchicalDataProvider), HasHierarchicalDataProvider.setItems(Collection, ValueProvider), HasHierarchicalDataProvider.setItems(Stream, ValueProvider) or HasHierarchicalDataProvider.setTreeData(TreeData) instead.
    void
    setDataProvider(com.vaadin.flow.data.provider.hierarchy.HierarchicalDataProvider<T,?> hierarchicalDataProvider)
     
    com.vaadin.flow.component.grid.Grid.Column<T>
    setHierarchyColumn(String propertyName)
    Note: This method can only be used for a TreeGrid created from a bean type with EnhancedTreeGrid(Class).
    com.vaadin.flow.component.grid.Grid.Column<T>
    setHierarchyColumn(String propertyName, com.vaadin.flow.function.ValueProvider<T,?> valueProvider)
    Note: This method can only be used for a TreeGrid created from a bean type with EnhancedTreeGrid(Class).
    com.vaadin.flow.component.grid.dataview.GridLazyDataView<T>
    setItems(com.vaadin.flow.data.provider.BackEndDataProvider<T,Void> dataProvider)
    Deprecated.
    use setDataProvider(HierarchicalDataProvider), HasHierarchicalDataProvider.setItems(Collection, ValueProvider), HasHierarchicalDataProvider.setItems(Stream, ValueProvider) or HasHierarchicalDataProvider.setTreeData(TreeData) instead.
    com.vaadin.flow.component.grid.dataview.GridLazyDataView<T>
    setItems(com.vaadin.flow.data.provider.CallbackDataProvider.FetchCallback<T,Void> fetchCallback)
    Deprecated.
    use setDataProvider(HierarchicalDataProvider), HasHierarchicalDataProvider.setItems(Collection, ValueProvider), HasHierarchicalDataProvider.setItems(Stream, ValueProvider) or HasHierarchicalDataProvider.setTreeData(TreeData) instead.
    com.vaadin.flow.component.grid.dataview.GridListDataView<T>
    setItems(com.vaadin.flow.data.provider.ListDataProvider<T> dataProvider)
    Deprecated.
    use setDataProvider(HierarchicalDataProvider), HasHierarchicalDataProvider.setItems(Collection, ValueProvider), HasHierarchicalDataProvider.setItems(Stream, ValueProvider) or HasHierarchicalDataProvider.setTreeData(TreeData) instead.
    com.vaadin.flow.component.grid.dataview.GridListDataView<T>
    Deprecated.
    use setDataProvider(HierarchicalDataProvider), HasHierarchicalDataProvider.setItems(Collection, ValueProvider), HasHierarchicalDataProvider.setItems(Stream, ValueProvider) or HasHierarchicalDataProvider.setTreeData(TreeData) instead.
    com.vaadin.flow.component.grid.dataview.GridListDataView<T>
    setItems(T... items)
    Deprecated.
    use setDataProvider(HierarchicalDataProvider), HasHierarchicalDataProvider.setItems(Collection, ValueProvider), HasHierarchicalDataProvider.setItems(Stream, ValueProvider) or HasHierarchicalDataProvider.setTreeData(TreeData) instead.
    void
    setUniqueKeyDataGenerator(String propertyName, com.vaadin.flow.function.ValueProvider<T,String> uniqueKeyProvider)
    Sets property name and value provider for unique key in row's generated JSON.

    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, getDefaultHeaderRow, getDragFilter, getDropFilter, getDropMode, getEditor, getEmptyStateComponent, getEmptyStateText, getFooterRows, getHeaderRows, 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, scrollToStart, select, setAllRowsVisible, setAriaLabel, setColumnKey, setColumnOrder, setColumnOrder, setColumnRendering, setColumnReorderingAllowed, setColumns, setDefaultMultiSortPriority, setDetailsVisible, setDetailsVisibleOnClick, setDragDataGenerator, setDragFilter, setDropFilter, setDropMode, setEmptyStateComponent, setEmptyStateText, setItemDetailsRenderer, 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.hierarchy.HasHierarchicalDataProvider

    getTreeData, setItems, setItems, setTreeData

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

    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

    • EnhancedTreeGrid

      public EnhancedTreeGrid()
      See Also:
      • TreeGrid()
    • EnhancedTreeGrid

      protected EnhancedTreeGrid(int pageSize, com.vaadin.flow.component.grid.Grid.DataCommunicatorBuilder<T,com.vaadin.flow.component.grid.GridArrayUpdater> dataCommunicatorBuilder)
      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:
      • TreeGrid(int, DataCommunicatorBuilder)
    • EnhancedTreeGrid

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

      public EnhancedTreeGrid(Class<T> beanType, boolean autoCreateColumns)
      Parameters:
      beanType - the bean type to use, not null
      autoCreateColumns - true to create columns automatically, false otherwise
      See Also:
      • TreeGrid(Class, boolean)
    • EnhancedTreeGrid

      public EnhancedTreeGrid(com.vaadin.flow.data.provider.hierarchy.HierarchicalDataProvider<T,?> dataProvider)
      Parameters:
      dataProvider - the data provider, not null
      See Also:
      • TreeGrid(HierarchicalDataProvider)
  • Method Details

    • setUniqueKeyDataGenerator

      public void setUniqueKeyDataGenerator(String propertyName, com.vaadin.flow.function.ValueProvider<T,String> uniqueKeyProvider)
      Sets property name and value provider for unique key in row's generated JSON.

      Default property name is 'key' and value is generated by bean's hashCode method.

      Parameters:
      propertyName - Property name in JSON data
      uniqueKeyProvider - Value provider for the target property in JSON data
    • addExpandListener

      public com.vaadin.flow.shared.Registration addExpandListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.treegrid.ExpandEvent<T,EnhancedTreeGrid<T>>> listener)
      Adds an ExpandEvent listener to this EnhancedTreeGrid.
      Parameters:
      listener - the listener to add
      Returns:
      a registration for the listener
      See Also:
      • ExpandEvent
    • addCollapseListener

      public com.vaadin.flow.shared.Registration addCollapseListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.treegrid.CollapseEvent<T,EnhancedTreeGrid<T>>> listener)
      Adds a CollapseEvent listener to this EnhancedTreeGrid.
      Parameters:
      listener - the listener to add
      Returns:
      a registration for the listener
      See Also:
      • CollapseEvent
    • setDataProvider

      public void setDataProvider(com.vaadin.flow.data.provider.DataProvider<T,?> dataProvider)
      Deprecated.
      use setDataProvider(HierarchicalDataProvider), HasHierarchicalDataProvider.setItems(Collection, ValueProvider), HasHierarchicalDataProvider.setItems(Stream, ValueProvider) or HasHierarchicalDataProvider.setTreeData(TreeData) instead.
      Tree grid only supports hierarchical data providers. Use setDataProvider(HierarchicalDataProvider) instead.

      This method is inherited from Grid and has been marked as deprecated to indicate that it is not supported. This method will throw an UnsupportedOperationException.

      Overrides:
      setDataProvider in class com.vaadin.flow.component.grid.Grid<T>
      Parameters:
      dataProvider - the data provider
    • setDataProvider

      public void setDataProvider(com.vaadin.flow.data.provider.hierarchy.HierarchicalDataProvider<T,?> hierarchicalDataProvider)
      Specified by:
      setDataProvider in interface com.vaadin.flow.data.provider.hierarchy.HasHierarchicalDataProvider<T>
    • setItems

      @Deprecated public com.vaadin.flow.component.grid.dataview.GridLazyDataView<T> setItems(com.vaadin.flow.data.provider.BackEndDataProvider<T,Void> dataProvider)
      Deprecated.
      use setDataProvider(HierarchicalDataProvider), HasHierarchicalDataProvider.setItems(Collection, ValueProvider), HasHierarchicalDataProvider.setItems(Stream, ValueProvider) or HasHierarchicalDataProvider.setTreeData(TreeData) instead.
      Tree grid does not support data views. Use setDataProvider(HierarchicalDataProvider) instead. This method is inherited from Grid and it will throw an UnsupportedOperationException.
      Specified by:
      setItems in interface com.vaadin.flow.data.provider.HasLazyDataView<T,Void,com.vaadin.flow.component.grid.dataview.GridLazyDataView<T>>
      Overrides:
      setItems in class com.vaadin.flow.component.grid.Grid<T>
      Parameters:
      dataProvider - the data provider
      Returns:
      the data view
    • setItems

      @Deprecated public com.vaadin.flow.component.grid.dataview.GridLazyDataView<T> setItems(com.vaadin.flow.data.provider.CallbackDataProvider.FetchCallback<T,Void> fetchCallback)
      Deprecated.
      use setDataProvider(HierarchicalDataProvider), HasHierarchicalDataProvider.setItems(Collection, ValueProvider), HasHierarchicalDataProvider.setItems(Stream, ValueProvider) or HasHierarchicalDataProvider.setTreeData(TreeData) instead.
      Tree grid supports only hierarchical data so use another method instead. This method is inherited from Grid and it will throw an UnsupportedOperationException.
      Specified by:
      setItems in interface com.vaadin.flow.data.provider.HasLazyDataView<T,Void,com.vaadin.flow.component.grid.dataview.GridLazyDataView<T>>
      Parameters:
      fetchCallback - the fetch callback
      Returns:
      the data view
    • setItems

      @Deprecated public com.vaadin.flow.component.grid.dataview.GridListDataView<T> setItems(com.vaadin.flow.data.provider.ListDataProvider<T> dataProvider)
      Deprecated.
      use setDataProvider(HierarchicalDataProvider), HasHierarchicalDataProvider.setItems(Collection, ValueProvider), HasHierarchicalDataProvider.setItems(Stream, ValueProvider) or HasHierarchicalDataProvider.setTreeData(TreeData) instead.
      Tree grid supports only hierarchical data providers so use another method instead. This method is inherited from Grid and it will throw an UnsupportedOperationException.
      Specified by:
      setItems in interface com.vaadin.flow.data.provider.HasListDataView<T,com.vaadin.flow.component.grid.dataview.GridListDataView<T>>
      Overrides:
      setItems in class com.vaadin.flow.component.grid.Grid<T>
      Parameters:
      dataProvider - the data provider
      Returns:
      the data view
    • setItems

      @Deprecated public com.vaadin.flow.component.grid.dataview.GridListDataView<T> setItems(T... items)
      Deprecated.
      use setDataProvider(HierarchicalDataProvider), HasHierarchicalDataProvider.setItems(Collection, ValueProvider), HasHierarchicalDataProvider.setItems(Stream, ValueProvider) or HasHierarchicalDataProvider.setTreeData(TreeData) instead.
      Tree grid supports only hierarchical data so use another method instead. This method is inherited from Grid and it will throw an UnsupportedOperationException.
      Specified by:
      setItems in interface com.vaadin.flow.data.provider.HasListDataView<T,com.vaadin.flow.component.grid.dataview.GridListDataView<T>>
      Parameters:
      items - the items to display, not null
      Returns:
      the data view
    • setItems

      @Deprecated public com.vaadin.flow.component.grid.dataview.GridListDataView<T> setItems(Collection<T> items)
      Deprecated.
      use setDataProvider(HierarchicalDataProvider), HasHierarchicalDataProvider.setItems(Collection, ValueProvider), HasHierarchicalDataProvider.setItems(Stream, ValueProvider) or HasHierarchicalDataProvider.setTreeData(TreeData) instead.
      Tree grid supports only hierarchical data, so use another method instead. This method is inherited from Grid and it will throw an UnsupportedOperationException.
      Specified by:
      setItems in interface com.vaadin.flow.data.provider.HasListDataView<T,com.vaadin.flow.component.grid.dataview.GridListDataView<T>>
      Parameters:
      items - the items to display, not null
      Returns:
      the data view
    • getListDataView

      @Deprecated public com.vaadin.flow.component.grid.dataview.GridListDataView<T> getListDataView()
      Deprecated.
      not supported
      Tree grid does not support list data view, this will throw an UnsupportedOperationException.
      Specified by:
      getListDataView in interface com.vaadin.flow.data.provider.HasListDataView<T,com.vaadin.flow.component.grid.dataview.GridListDataView<T>>
      Overrides:
      getListDataView in class com.vaadin.flow.component.grid.Grid<T>
      Returns:
      exception is thrown
    • getLazyDataView

      @Deprecated public com.vaadin.flow.component.grid.dataview.GridLazyDataView<T> getLazyDataView()
      Deprecated.
      not supported
      Tree grid does not support list data view, this will throw an UnsupportedOperationException.
      Specified by:
      getLazyDataView in interface com.vaadin.flow.data.provider.HasLazyDataView<T,Void,com.vaadin.flow.component.grid.dataview.GridLazyDataView<T>>
      Overrides:
      getLazyDataView in class com.vaadin.flow.component.grid.Grid<T>
      Returns:
      exception is thrown
    • getGenericDataView

      @Deprecated public com.vaadin.flow.component.grid.dataview.GridDataView<T> getGenericDataView()
      Deprecated.
      not supported
      Tree grid does not support list data view, this will throw an UnsupportedOperationException.
      Specified by:
      getGenericDataView in interface com.vaadin.flow.data.provider.HasDataView<T,Void,com.vaadin.flow.component.grid.dataview.GridDataView<T>>
      Overrides:
      getGenericDataView in class com.vaadin.flow.component.grid.Grid<T>
      Returns:
      exception is thrown
    • addHierarchyColumn

      public EnhancedColumn<T> addHierarchyColumn(com.vaadin.flow.function.ValueProvider<T,?> valueProvider)
      Adds a new Hierarchy column to this Grid with a value provider. The value is converted to String when sent to the client by using String.valueOf(Object).

      Hierarchy column is rendered by using 'vaadin-grid-tree-toggle' web component.

      Parameters:
      valueProvider - the value provider
      Returns:
      the created hierarchy column
    • addComponentHierarchyColumn

      public <V extends com.vaadin.flow.component.Component> EnhancedColumn<T> addComponentHierarchyColumn(com.vaadin.flow.function.ValueProvider<T,V> componentProvider)
      Adds a new Hierarchy column that shows components.

      NOTE: Using ComponentRenderer is not as efficient as the built in renderers.

      Type Parameters:
      V - the component type
      Parameters:
      componentProvider - a value provider that will return a component for the given item
      Returns:
      the new column
      See Also:
    • setHierarchyColumn

      public com.vaadin.flow.component.grid.Grid.Column<T> setHierarchyColumn(String propertyName)
      Note: This method can only be used for a TreeGrid created from a bean type with EnhancedTreeGrid(Class).

      Resets columns and their order based on bean properties.

      This is a shortcut for removing all columns and then calling Grid.addColumn(String) for each property except hierarchy column in the bean and addHierarchyColumn(String) for the given propertyName.

      Previous column order is preserved.

      You can add columns for nested properties with dot notation, eg. "property.nestedProperty"

      Note that this also resets the headers and footers.

      Parameters:
      propertyName - a target hierarchy column property name
      Returns:
      the created hierarchy column
    • setHierarchyColumn

      public com.vaadin.flow.component.grid.Grid.Column<T> setHierarchyColumn(String propertyName, com.vaadin.flow.function.ValueProvider<T,?> valueProvider)
      Note: This method can only be used for a TreeGrid created from a bean type with EnhancedTreeGrid(Class).

      Resets columns and their order based on bean properties.

      This is a shortcut for removing all columns and then calling Grid.addColumn(String) for each property except hierarchy column in the bean and addHierarchyColumn(String) or addHierarchyColumn(ValueProvider) for the given propertyName.

      Previous column order is preserved.

      You can add columns for nested properties with dot notation, eg. "property.nestedProperty"

      Note that this also resets the headers and footers.

      Parameters:
      propertyName - a target hierarchy column property name
      valueProvider - optional value provider
      Returns:
      the created hierarchy column
    • setColumns

      public com.vaadin.flow.component.grid.Grid.Column<T> setColumns(String hierarchyPropertyName, com.vaadin.flow.function.ValueProvider<T,?> valueProvider, Collection<String> propertyNames)
      Note: This method can only be used for a TreeGrid created from a bean type with EnhancedTreeGrid(Class).

      Sets the columns and their order based on the given properties.

      This is a shortcut for removing all columns and then calling Grid.addColumn(String) for each property except hierarchy property in the bean and addHierarchyColumn(String) for the given hierarchyPropertyName.

      You can add columns for nested properties with dot notation, eg. "property.nestedProperty"

      Note that this also resets the headers and footers.

      Parameters:
      hierarchyPropertyName - a target hierarchy column property name
      valueProvider - optional value provider
      propertyNames - set of properties to create columns for. Including given hierarchyPropertyName
      Returns:
      the hierarchy column
    • expand

      public void expand(T... items)
      Expands the given items.

      If an item is currently expanded, does nothing. If an item does not have any children, does nothing.

      Parameters:
      items - the items to expand
    • expand

      public void expand(Collection<T> items)
      Expands the given items.

      If an item is currently expanded, does nothing. If an item does not have any children, does nothing.

      Parameters:
      items - the items to expand
    • expand

      protected void expand(Collection<T> items, boolean userOriginated)
      Expands the given items.
      Parameters:
      items - the items to expand
      userOriginated - true if a ExpandEvent triggered by this operation is user originated, false otherwise.
    • expandRecursively

      public void expandRecursively(Stream<T> items, int depth)
      Expands the given items and their children recursively until the given depth.

      depth describes the maximum distance between a given item and its descendant, meaning that expandRecursively(items, 0) expands only the given items while expandRecursively(items, 2) expands the given items as well as their children and grandchildren.

      This method will not fire events for expanded nodes.

      Parameters:
      items - the items to expand recursively
      depth - the maximum depth of recursion
      Since:
      8.4
    • expandRecursively

      public void expandRecursively(Collection<T> items, int depth)
      Expands the given items and their children recursively until the given depth.

      depth describes the maximum distance between a given item and its descendant, meaning that expandRecursively(items, 0) expands only the given items while expandRecursively(items, 2) expands the given items as well as their children and grandchildren.

      This method will not fire events for expanded nodes.

      Parameters:
      items - the items to expand recursively
      depth - the maximum depth of recursion
      Since:
      8.4
    • collapse

      public void collapse(T... items)
      Collapse the given items.

      For items that are already collapsed, does nothing.

      Parameters:
      items - the collection of items to collapse
    • collapse

      public void collapse(Collection<T> items)
      Collapse the given items.

      For items that are already collapsed, does nothing.

      Parameters:
      items - the collection of items to collapse
    • collapse

      protected void collapse(Collection<T> items, boolean userOriginated)
      Collapse the given items.
      Parameters:
      items - the collection of items to collapse
      userOriginated - true if a CollapseEvent triggered by this operation is user originated, false otherwise.
    • collapseRecursively

      public void collapseRecursively(Stream<T> items, int depth)
      Collapse the given items and their children recursively until the given depth.

      depth describes the maximum distance between a given item and its descendant, meaning that collapseRecursively(items, 0) collapses only the given items while collapseRecursively(items, 2) collapses the given items as well as their children and grandchildren.

      This method will not fire events for collapsed nodes.

      Parameters:
      items - the items to collapse recursively
      depth - the maximum depth of recursion
      Since:
      8.4
    • collapseRecursively

      public void collapseRecursively(Collection<T> items, int depth)
      Collapse the given items and their children recursively until the given depth.

      depth describes the maximum distance between a given item and its descendant, meaning that collapseRecursively(items, 0) collapses only the given items while collapseRecursively(items, 2) collapses the given items as well as their children and grandchildren.

      This method will not fire events for collapsed nodes.

      Parameters:
      items - the items to collapse recursively
      depth - the maximum depth of recursion
      Since:
      8.4
    • getItemsWithChildrenRecursively

      protected Collection<T> getItemsWithChildrenRecursively(Collection<T> items, int depth)
      Gets given items and their children recursively until the given depth.

      depth describes the maximum distance between a given item and its descendant, meaning that getItemsWithChildrenRecursively(items, 0) gets only the given items while getItemsWithChildrenRecursively(items, 2) gets the given items as well as their children and grandchildren.

      Parameters:
      items - the items to expand recursively
      depth - the maximum depth of recursion
      Returns:
      collection of given items and their children recursively until the given depth
    • isExpanded

      public boolean isExpanded(T item)
      Returns whether a given item is expanded or collapsed.
      Parameters:
      item - the item to check
      Returns:
      true if the item is expanded, false if collapsed
    • getDataCommunicator

      public com.vaadin.flow.data.provider.hierarchy.HierarchicalDataCommunicator<T> getDataCommunicator()
      Overrides:
      getDataCommunicator in class com.vaadin.flow.component.grid.Grid<T>
    • getDataProvider

      public com.vaadin.flow.data.provider.hierarchy.HierarchicalDataProvider<T,com.vaadin.flow.function.SerializablePredicate<T>> getDataProvider()
      Specified by:
      getDataProvider in interface com.vaadin.flow.data.provider.hierarchy.HasHierarchicalDataProvider<T>
      Overrides:
      getDataProvider in class com.vaadin.flow.component.grid.Grid<T>
    • scrollToIndex

      public void scrollToIndex(int index)
      Scrolls to the index of an item so that the row is shown at the start of the visible area whenever possible. The way the index parameter is interpreted depends on the hierarchy format of the current data provider:

      HierarchicalDataProvider.HierarchyFormat.NESTED: the index refers to an item in the root level. To reach items in deeper levels, use scrollToIndex(int...), which accepts a hierarchical path.

      HierarchicalDataProvider.HierarchyFormat.FLATTENED: the index refers to an item in the entire flattened tree, not only the root level, allowing items at any expanded level to be reached with this method.

      If the index exceeds the valid range, scrolling stops at the last available item.

      Overrides:
      scrollToIndex in class com.vaadin.flow.component.grid.Grid<T>
      Parameters:
      index - zero based index of the item to scroll to
    • scrollToIndex

      public void scrollToIndex(int... path)
      Scrolls to a nested item specified by its hierarchical path.

      The hierarchical path is an array of zero-based indexes, where each index refers to a child of the item at the previous index. Scrolling continues until it reaches the last index in the array or encounters a collapsed item.

      For example, given &#123; 2, 1, ... &#125; as the path, the component will first try to scroll to the item at index 2 in the root level. If that item is expanded, it will then try to scroll to the item at index 1 among its children, and so forth.

      This method is only supported for data providers that use HierarchicalDataProvider.HierarchyFormat.NESTED. For HierarchicalDataProvider.HierarchyFormat.FLATTENED, use scrollToIndex(int) with a flat index instead.

      Parameters:
      path - an array of indexes representing the path to the target item
      Throws:
      IllegalArgumentException - if the path is empty
      UnsupportedOperationException - if the data provider uses a hierarchy format other than HierarchicalDataProvider.HierarchyFormat.NESTED
    • scrollToEnd

      public void scrollToEnd()
      Overrides:
      scrollToEnd in class com.vaadin.flow.component.grid.Grid<T>
    • scrollToItem

      public void scrollToItem(T item)
      Overrides:
      scrollToItem in class com.vaadin.flow.component.grid.Grid<T>
      Parameters:
      item - the item to scroll to
      Throws:
      NoSuchElementException - if the item does not belong to the tree
      See Also:
      • TreeGrid.scrollToItem(Object)
    • applyFilterPredicate

      protected void applyFilterPredicate(com.vaadin.flow.function.SerializablePredicate<T> finalPredicate)
      Description copied from class: EnhancedGrid
      Apply filter predicate depending on the data provider
      Overrides:
      applyFilterPredicate in class EnhancedGrid<T>
      Parameters:
      finalPredicate -