Class TreeGridPro<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>>,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>,Serializable
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.vaadin.flow.component.gridpro.AbstractGridPro
AbstractGridPro.CellEditStartedEvent<E>, AbstractGridPro.EditColumn<T>, AbstractGridPro.ItemPropertyChangedEvent<E>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 newTreeGridwithout support for creating columns based on property names.protectedTreeGridPro(int pageSize, TreeGridPro.TreeDataCommunicatorBuilder<T> dataCommunicatorBuilder) Creates a newTreeGridwithout support for creating columns based on property names.TreeGridPro(com.vaadin.flow.data.provider.hierarchy.HierarchicalDataProvider<T, ?> dataProvider) Creates a newTreeGridusing the givenHierarchicalDataProvider, without support for creating columns based on property names.TreeGridPro(Class<T> beanType) Creates a newTreeGridwith an initial set of columns for each of the bean's properties.TreeGridPro(Class<T> beanType, boolean autoCreateColumns) Creates a newTreeGridwith an initial set of columns for each of the bean's properties.protectedTreeGridPro(Class<T> beanType, TreeGridPro.TreeDataCommunicatorBuilder<T> dataCommunicatorBuilder) Creates a newTreeGridwith an initial set of columns for each of the bean's properties. -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.RegistrationaddCollapseListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.treegrid.CollapseEvent<T, TreeGridPro<T>>> listener) Adds a CollapseEvent listener to this TreeGrid.<V extends com.vaadin.flow.component.Component>
com.vaadin.flow.component.grid.Grid.Column<T> addComponentHierarchyColumn(com.vaadin.flow.function.ValueProvider<T, V> componentProvider) Adds a new Hierarchy column that shows components.com.vaadin.flow.shared.RegistrationaddExpandListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.treegrid.ExpandEvent<T, TreeGridPro<T>>> listener) Adds an ExpandEvent listener to this TreeGrid.com.vaadin.flow.component.grid.Grid.Column<T> addHierarchyColumn(com.vaadin.flow.function.ValueProvider<T, ?> valueProvider) Adds a new Hierarchy column to thisGridwith a value provider.voidcollapse(Collection<T> items) Collapse the given items.protected voidcollapse(Collection<T> items, boolean userOriginated) Collapse the given items.voidCollapse the given items.voidcollapseRecursively(Collection<T> items, int depth) Collapse the given items and their children recursively until the given depth.voidcollapseRecursively(Stream<T> items, int depth) Collapse the given items and their children recursively until the given depth.voidexpand(Collection<T> items) Expands the given items.protected voidexpand(Collection<T> items, boolean userOriginated) Expands the given items.voidExpands the given items.voidexpandRecursively(Collection<T> items, int depth) Expands the given items and their children recursively until the given depth.voidexpandRecursively(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 supportedprotected Collection<T> getItemsWithChildrenRecursively(Collection<T> items, int depth) Gets given items and their children recursively until the given depth.com.vaadin.flow.component.grid.dataview.GridLazyDataView<T> Deprecated.not supportedcom.vaadin.flow.component.grid.dataview.GridListDataView<T> Deprecated.not supportedbooleanisExpanded(T item) Returns whether a given item is expanded or collapsed.voidvoidscrollToIndex(int index) Scrolls to the index of an item so that the row is shown at the start of the visible area whenever possible.voidscrollToIndex(int... path) Scrolls to a nested item specified by its hierarchical path.voidscrollToItem(T item) Scrolls to the given item unless it is already fully visible.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.invalid reference
#TreeGrid(Class)voidsetDataProvider(com.vaadin.flow.data.provider.DataProvider<T, ?> dataProvider) Deprecated.usesetDataProvider(HierarchicalDataProvider),HasHierarchicalDataProvider.setItems(Collection, ValueProvider),HasHierarchicalDataProvider.setItems(Stream, ValueProvider)orHasHierarchicalDataProvider.setTreeData(TreeData)instead.voidsetDataProvider(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.invalid reference
#TreeGrid(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.invalid reference
#TreeGrid(Class)com.vaadin.flow.component.grid.dataview.GridLazyDataView<T> Deprecated.usesetDataProvider(HierarchicalDataProvider),HasHierarchicalDataProvider.setItems(Collection, ValueProvider),HasHierarchicalDataProvider.setItems(Stream, ValueProvider)orHasHierarchicalDataProvider.setTreeData(TreeData)instead.com.vaadin.flow.component.grid.dataview.GridLazyDataView<T> Deprecated.usesetDataProvider(HierarchicalDataProvider),HasHierarchicalDataProvider.setItems(Collection, ValueProvider),HasHierarchicalDataProvider.setItems(Stream, ValueProvider)orHasHierarchicalDataProvider.setTreeData(TreeData)instead.com.vaadin.flow.component.grid.dataview.GridListDataView<T> Deprecated.usesetDataProvider(HierarchicalDataProvider),HasHierarchicalDataProvider.setItems(Collection, ValueProvider),HasHierarchicalDataProvider.setItems(Stream, ValueProvider)orHasHierarchicalDataProvider.setTreeData(TreeData)instead.com.vaadin.flow.component.grid.dataview.GridListDataView<T> setItems(Collection<T> items) Deprecated.usesetDataProvider(HierarchicalDataProvider),HasHierarchicalDataProvider.setItems(Collection, ValueProvider),HasHierarchicalDataProvider.setItems(Stream, ValueProvider)orHasHierarchicalDataProvider.setTreeData(TreeData)instead.com.vaadin.flow.component.grid.dataview.GridListDataView<T> Deprecated.usesetDataProvider(HierarchicalDataProvider),HasHierarchicalDataProvider.setItems(Collection, ValueProvider),HasHierarchicalDataProvider.setItems(Stream, ValueProvider)orHasHierarchicalDataProvider.setTreeData(TreeData)instead.voidsetUniqueKeyDataGenerator(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.gridpro.AbstractGridPro
addCellEditStartedListener, addEditColumn, addEditColumn, addEditColumn, addEditColumn, addItemPropertyChangedListener, addThemeVariants, createEditColumn, getEditOnClick, getEnterNextRow, getSingleCellEdit, onEnabledStateChanged, removeThemeVariants, setEditOnClick, setEnterNextRow, setSingleCellEditMethods inherited from class com.vaadin.flow.component.grid.Grid
addCellFocusListener, addColumn, addColumn, addColumn, addColumn, addColumn, addColumn, addColumn, addColumnReorderListener, addColumnResizeListener, addColumns, addComponentColumn, 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, getColumnByKey, getColumnLayers, getColumnRendering, getColumns, getDefaultColumnFactory, 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, onAttach, onDataProviderChange, onDetach, 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, setPartNameGenerator, setRowsDraggable, setSelectionDragDetails, setSelectionMode, 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.hierarchy.HasHierarchicalDataProvider
getTreeData, setItems, setItems, setTreeDataMethods inherited from interface com.vaadin.flow.data.provider.HasLazyDataView
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
-
TreeGridPro
public TreeGridPro()Creates a newTreeGridwithout support for creating columns based on property names. Use an alternative constructor, such as, to create ainvalid reference
TreeGridPro#TreeGrid(Class)TreeGridthat automatically sets up columns based on the type of presented data. -
TreeGridPro
protected TreeGridPro(int pageSize, TreeGridPro.TreeDataCommunicatorBuilder<T> dataCommunicatorBuilder) Creates a newTreeGridwithout support for creating columns based on property names. Use an alternative constructor, such asTreeGrid(Class), to create aTreeGridthat automatically sets up columns based on the type of presented data.- Parameters:
pageSize- the page size. Must be greater than zero.dataCommunicatorBuilder- Builder forDataCommunicatorimplementation this Grid uses to handle all data communication.
-
TreeGridPro
Creates a newTreeGridwith an initial set of columns for each of the bean's properties. The property-values of the bean will be converted to Strings. Full names of the properties will be used as thecolumn keysand the property captions will be used as thecolumn headers.- Parameters:
beanType- the bean type to use, notnull
-
TreeGridPro
Creates a newTreeGridwith an initial set of columns for each of the bean's properties. The property-values of the bean will be converted to Strings. Full names of the properties will be used as thecolumn keysand the property captions will be used as thecolumn headers.When autoCreateColumns is
true, only the direct properties of the bean are included, and they will be in alphabetical order. UseGrid.setColumns(String...)to define which properties to include and in which order. You can also add a column for an individual property withGrid.addColumn(String). Both of these methods support also sub-properties with dot-notation, e.g."property.nestedProperty".- Parameters:
beanType- the bean type to use, notnullautoCreateColumns- whentrue, columns are created automatically for the properties of the beanType
-
TreeGridPro
protected TreeGridPro(Class<T> beanType, TreeGridPro.TreeDataCommunicatorBuilder<T> dataCommunicatorBuilder) Creates a newTreeGridwith an initial set of columns for each of the bean's properties. The property-values of the bean will be converted to Strings. Full names of the properties will be used as thecolumn keysand the property captions will be used as thecolumn headers.- Parameters:
beanType- the bean type to use, notnulldataCommunicatorBuilder- Builder forDataCommunicatorimplementation this Grid uses to handle all data communication.
-
TreeGridPro
public TreeGridPro(com.vaadin.flow.data.provider.hierarchy.HierarchicalDataProvider<T, ?> dataProvider) Creates a newTreeGridusing the givenHierarchicalDataProvider, without support for creating columns based on property names. Use an alternative constructor, such as, to create ainvalid reference
TreeGridPro#TreeGrid(Class)TreeGridthat automatically sets up columns based on the type of presented data.- Parameters:
dataProvider- the data provider, notnull
-
-
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 datauniqueKeyProvider- 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, TreeGridPro<T>>> listener) Adds an ExpandEvent listener to this TreeGrid.- Parameters:
listener- the listener to add- Returns:
- a registration for the listener
- See Also:
-
addCollapseListener
public com.vaadin.flow.shared.Registration addCollapseListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.treegrid.CollapseEvent<T, TreeGridPro<T>>> listener) Adds a CollapseEvent listener to this TreeGrid.- Parameters:
listener- the listener to add- Returns:
- a registration for the listener
- See Also:
-
setDataProvider
Deprecated.usesetDataProvider(HierarchicalDataProvider),HasHierarchicalDataProvider.setItems(Collection, ValueProvider),HasHierarchicalDataProvider.setItems(Stream, ValueProvider)orHasHierarchicalDataProvider.setTreeData(TreeData)instead.Tree grid only supports hierarchical data providers. UsesetDataProvider(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:
setDataProviderin classcom.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:
setDataProviderin interfacecom.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.usesetDataProvider(HierarchicalDataProvider),HasHierarchicalDataProvider.setItems(Collection, ValueProvider),HasHierarchicalDataProvider.setItems(Stream, ValueProvider)orHasHierarchicalDataProvider.setTreeData(TreeData)instead.Tree grid does not support data views. UsesetDataProvider(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. -
setItems
@Deprecated public com.vaadin.flow.component.grid.dataview.GridLazyDataView<T> setItems(com.vaadin.flow.data.provider.CallbackDataProvider.FetchCallback<T, Void> fetchCallback) Deprecated.usesetDataProvider(HierarchicalDataProvider),HasHierarchicalDataProvider.setItems(Collection, ValueProvider),HasHierarchicalDataProvider.setItems(Stream, ValueProvider)orHasHierarchicalDataProvider.setTreeData(TreeData)instead.Tree grid supports only hierarchical data so use another method 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. -
setItems
@Deprecated public com.vaadin.flow.component.grid.dataview.GridListDataView<T> setItems(com.vaadin.flow.data.provider.ListDataProvider<T> dataProvider) Deprecated.usesetDataProvider(HierarchicalDataProvider),HasHierarchicalDataProvider.setItems(Collection, ValueProvider),HasHierarchicalDataProvider.setItems(Stream, ValueProvider)orHasHierarchicalDataProvider.setTreeData(TreeData)instead.Tree grid supports only hierarchical data providers so use another method 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. -
setItems
Deprecated.usesetDataProvider(HierarchicalDataProvider),HasHierarchicalDataProvider.setItems(Collection, ValueProvider),HasHierarchicalDataProvider.setItems(Stream, ValueProvider)orHasHierarchicalDataProvider.setTreeData(TreeData)instead.Tree grid supports only hierarchical data so use another method 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. -
setItems
@Deprecated public com.vaadin.flow.component.grid.dataview.GridListDataView<T> setItems(Collection<T> items) Deprecated.usesetDataProvider(HierarchicalDataProvider),HasHierarchicalDataProvider.setItems(Collection, ValueProvider),HasHierarchicalDataProvider.setItems(Stream, ValueProvider)orHasHierarchicalDataProvider.setTreeData(TreeData)instead.Tree grid supports only hierarchical data, so use another method 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. -
getListDataView
Deprecated.not supportedTree grid does not support list data view.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. -
getLazyDataView
Deprecated.not supportedTree grid does not support list data view.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. -
getGenericDataView
Deprecated.not supportedTree grid does not support list data view.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. -
addHierarchyColumn
public com.vaadin.flow.component.grid.Grid.Column<T> addHierarchyColumn(com.vaadin.flow.function.ValueProvider<T, ?> valueProvider) Adds a new Hierarchy column to thisGridwith a value provider. The value is converted to String when sent to the client by usingString.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> com.vaadin.flow.component.grid.Grid.Column<T> addComponentHierarchyColumn(com.vaadin.flow.function.ValueProvider<T, V> componentProvider) Adds a new Hierarchy column that shows components.NOTE: Using
ComponentRendereris 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
Note: This method can only be used for a TreeGrid created from a bean type with.invalid reference
#TreeGrid(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 andaddHierarchyColumn(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.invalid reference
#TreeGrid(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 andaddHierarchyColumn(String)oraddHierarchyColumn(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 namevalueProvider- 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.invalid reference
#TreeGrid(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 andaddHierarchyColumn(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 namevalueProvider- optional value providerpropertyNames- set of properties to create columns for. Including given hierarchyPropertyName- Returns:
- the hierarchy column
-
expand
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
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
Expands the given items.- Parameters:
items- the items to expanduserOriginated-trueif aExpandEventtriggered by this operation is user originated,falseotherwise.
-
expandRecursively
Expands the given items and their children recursively until the given depth.depthdescribes the maximum distance between a given item and its descendant, meaning thatexpandRecursively(items, 0)expands only the given items whileexpandRecursively(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 recursivelydepth- the maximum depth of recursion- Since:
- 8.4
-
expandRecursively
Expands the given items and their children recursively until the given depth.depthdescribes the maximum distance between a given item and its descendant, meaning thatexpandRecursively(items, 0)expands only the given items whileexpandRecursively(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 recursivelydepth- the maximum depth of recursion- Since:
- 8.4
-
collapse
Collapse the given items.For items that are already collapsed, does nothing.
- Parameters:
items- the collection of items to collapse
-
collapse
Collapse the given items.For items that are already collapsed, does nothing.
- Parameters:
items- the collection of items to collapse
-
collapse
Collapse the given items.- Parameters:
items- the collection of items to collapseuserOriginated-trueif aCollapseEventtriggered by this operation is user originated,falseotherwise.
-
collapseRecursively
Collapse the given items and their children recursively until the given depth.depthdescribes the maximum distance between a given item and its descendant, meaning thatcollapseRecursively(items, 0)collapses only the given items whilecollapseRecursively(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 recursivelydepth- the maximum depth of recursion- Since:
- 8.4
-
collapseRecursively
Collapse the given items and their children recursively until the given depth.depthdescribes the maximum distance between a given item and its descendant, meaning thatcollapseRecursively(items, 0)collapses only the given items whilecollapseRecursively(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 recursivelydepth- the maximum depth of recursion- Since:
- 8.4
-
getItemsWithChildrenRecursively
Gets given items and their children recursively until the given depth.depthdescribes the maximum distance between a given item and its descendant, meaning thatgetItemsWithChildrenRecursively(items, 0)gets only the given items whilegetItemsWithChildrenRecursively(items, 2)gets the given items as well as their children and grandchildren.- Parameters:
items- the items to expand recursivelydepth- the maximum depth of recursion- Returns:
- collection of given items and their children recursively until the given depth
-
isExpanded
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:
getDataCommunicatorin classcom.vaadin.flow.component.grid.Grid<T>
-
getDataProvider
-
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 theindexparameter is interpreted depends on thehierarchy formatof the current data provider:HierarchicalDataProvider.HierarchyFormat.NESTED: the index refers to an item in the root level. To reach items in deeper levels, usescrollToIndex(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:
scrollToIndexin classcom.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
{ 2, 1, ... }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. ForHierarchicalDataProvider.HierarchyFormat.FLATTENED, usescrollToIndex(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 emptyUnsupportedOperationException- if the data provider uses a hierarchy format other thanHierarchicalDataProvider.HierarchyFormat.NESTED
-
scrollToEnd
public void scrollToEnd()- Overrides:
scrollToEndin classcom.vaadin.flow.component.grid.Grid<T>
-
scrollToItem
Scrolls to the given item unless it is already fully visible. Before scrolling, this method automatically expands all ancestor items leading to the target item, but it does not fire anyExpandEventwhile doing so.For this method to work, the data provider must implement two methods:
andinvalid reference
HierarchicalDataProvider#getParent(T).invalid reference
HierarchicalDataProvider#getItemIndex(T, HierarchicalQuery)Depending on the type of data provider, some of these methods may already be implemented. Otherwise, you have to implement them manually. The table below shows which methods are required in each case:
DataProvider isInMemory()invalid reference
getItemIndex(item, query)invalid reference
getParent(item)TreeDataProvidertrue not required not required HierarchicalDataProvidertrue not required required HierarchicalDataProviderfalse required required - Overrides:
scrollToItemin classcom.vaadin.flow.component.grid.Grid<T>- Parameters:
item- the item to scroll to- Throws:
NoSuchElementException- if the item does not belong to the tree
-