T
- the grid bean type@JsModule(value="@vaadin/vaadin-grid/src/vaadin-grid-tree-toggle.js") @HtmlImport(value="frontend://bower_components/vaadin-grid/src/vaadin-grid-tree-toggle.html") public class TreeGrid<T> extends Grid<T> implements HasHierarchicalDataProvider<T>
Grid.AbstractGridExtension<T>, Grid.Column<T>, Grid.DataCommunicatorBuilder<T,U extends ArrayUpdater>, Grid.NestedNullBehavior, Grid.SelectionMode, Grid.UpdateQueue
BlurNotifier.BlurEvent<C extends Component>
FocusNotifier.FocusEvent<C extends Component>
Constructor and Description |
---|
TreeGrid()
Creates a new
TreeGrid without support for creating columns based
on property names. |
TreeGrid(Class<T> beanType)
Creates a new
TreeGrid with an initial set of columns for each of
the bean's properties. |
TreeGrid(HierarchicalDataProvider<T,?> dataProvider)
Creates a new
TreeGrid using the given
HierarchicalDataProvider , without support for creating columns
based on property names. |
Modifier and Type | Method and Description |
---|---|
Registration |
addCollapseListener(ComponentEventListener<CollapseEvent<T,TreeGrid<T>>> listener)
Adds a CollapseEvent listener to this TreeGrid.
|
<V extends Component> |
addComponentHierarchyColumn(ValueProvider<T,V> componentProvider)
Adds a new Hierarchy column that shows components.
|
Registration |
addExpandListener(ComponentEventListener<ExpandEvent<T,TreeGrid<T>>> listener)
Adds an ExpandEvent listener to this TreeGrid.
|
Grid.Column<T> |
addHierarchyColumn(ValueProvider<T,?> valueProvider)
Adds a new Hierarchy column to this
Grid with a value provider. |
void |
collapse(Collection<T> items)
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.
|
protected GridArrayUpdater |
createDefaultArrayUpdater(SerializableBiFunction<GridArrayUpdater.UpdateQueueData,Integer,Grid.UpdateQueue> updateQueueFactory) |
void |
expand(Collection<T> items)
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.
|
HierarchicalDataCommunicator<T> |
getDataCommunicator()
Returns the data communicator of this Grid.
|
HierarchicalDataProvider<T,SerializablePredicate<T>> |
getDataProvider()
Returns the data provider of this grid.
|
protected Collection<T> |
getItemsWithChildrenRecursively(Collection<T> items,
int depth)
Gets given items and their children recursively until the given depth.
|
boolean |
isExpanded(T item)
Returns whether a given item is expanded or collapsed.
|
Grid.Column<T> |
setColumns(String hierarchyPropertyName,
ValueProvider<T,?> valueProvider,
Collection<String> propertyNames)
Note: This method can only be used for a TreeGrid
created from a bean type with
TreeGrid(Class) . |
void |
setDataProvider(DataProvider<T,?> dataProvider)
Sets the data provider for this listing.
|
Grid.Column<T> |
setHierarchyColumn(String propertyName)
Note: This method can only be used for a TreeGrid
created from a bean type with
TreeGrid(Class) . |
Grid.Column<T> |
setHierarchyColumn(String propertyName,
ValueProvider<T,?> valueProvider)
Note: This method can only be used for a TreeGrid
created from a bean type with
TreeGrid(Class) . |
void |
setUniqueKeyDataGenerator(String propertyName,
ValueProvider<T,String> uniqueKeyProvider)
Sets property name and value provider for unique key in row's generated
JSON.
|
addCellFocusListener, addColumn, addColumn, 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, createColumn, createColumnId, createEditor, createSortingComparator, deselect, deselectAll, getArrayUpdater, getBeanType, getClassNameGenerator, getColumnByKey, getColumnLayers, getColumns, getDefaultColumnFactory, getDefaultHeaderRow, getDragFilter, getDropFilter, getDropMode, getEditor, getFooterRows, getHeaderRows, getNestedNullBehavior, getPageSize, getPropertySet, getSelectedItems, getSelectionModel, getSortOrder, getUniqueKeyProperty, getUniqueKeyProvider, initConnector, insertColumnLayer, isAllRowsVisible, isColumnReorderingAllowed, isDetailsVisible, isDetailsVisibleOnClick, isHeightByRows, isMultiSort, isRowsDraggable, isVerticalScrollingEnabled, onAttach, onDataProviderChange, onDetach, onEnabledStateChanged, prependFooterRow, prependHeaderRow, recalculateColumnWidths, removeAllColumns, removeColumn, removeColumnByKey, removeColumnLayer, removeColumns, removeDataGenerator, removeThemeVariants, scrollToEnd, scrollToIndex, scrollToStart, select, setAllRowsVisible, setClassNameGenerator, setColumnKey, setColumnOrder, setColumnOrder, setColumnReorderingAllowed, setColumns, setDetailsVisible, setDetailsVisibleOnClick, setDragDataGenerator, setDragFilter, setDropFilter, setDropMode, setHeightByRows, setItemDetailsRenderer, setMultiSort, setNestedNullBehavior, setPageSize, setRowsDraggable, setSelectionDragDetails, setSelectionMode, setSelectionModel, setSortableColumns, setUniqueKeyProperty, setUniqueKeyProvider, setVerticalScrollingEnabled, sort, updateSelectionModeOnClient
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, set, setElement, setId, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getTreeData, setItems, setItems, setItems, setItems, setItems, setTreeData
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
getCssSize, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
addFocusShortcut, blur, focus, getTabIndex, setTabIndex
addBlurListener
addFocusListener
isEnabled, setEnabled
getElement
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
addAttachListener
addDetachListener
public TreeGrid()
TreeGrid
without support for creating columns based
on property names. Use an alternative constructor, such as
TreeGrid(Class)
, to create a TreeGrid
that
automatically sets up columns based on the type of presented data.public TreeGrid(Class<T> beanType)
TreeGrid
with 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 the
column keys
and the property captions will
be used as the column headers
.beanType
- the bean type to use, not null
public TreeGrid(HierarchicalDataProvider<T,?> dataProvider)
TreeGrid
using the given
HierarchicalDataProvider
, without support for creating columns
based on property names. Use an alternative constructor, such as
TreeGrid(Class)
, to create a TreeGrid
that
automatically sets up columns based on the type of presented data.dataProvider
- the data provider, not null
protected GridArrayUpdater createDefaultArrayUpdater(SerializableBiFunction<GridArrayUpdater.UpdateQueueData,Integer,Grid.UpdateQueue> updateQueueFactory)
createDefaultArrayUpdater
in class Grid<T>
public void setUniqueKeyDataGenerator(String propertyName, ValueProvider<T,String> uniqueKeyProvider)
Default property name is 'key' and value is generated by bean's hashCode method.
propertyName
- Property name in JSON datauniqueKeyProvider
- Value provider for the target property in JSON datapublic Registration addExpandListener(ComponentEventListener<ExpandEvent<T,TreeGrid<T>>> listener)
listener
- the listener to addExpandEvent
public Registration addCollapseListener(ComponentEventListener<CollapseEvent<T,TreeGrid<T>>> listener)
listener
- the listener to addCollapseEvent
public void setDataProvider(DataProvider<T,?> dataProvider)
HasDataProvider
setDataProvider
in interface HasDataProvider<T>
setDataProvider
in class Grid<T>
dataProvider
- the data provider, not nullpublic Grid.Column<T> addHierarchyColumn(ValueProvider<T,?> valueProvider)
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.
valueProvider
- the value providerpublic <V extends Component> Grid.Column<T> addComponentHierarchyColumn(ValueProvider<T,V> componentProvider)
NOTE: Using ComponentRenderer
is not as efficient as the
built in renderers.
V
- the component typecomponentProvider
- a value provider that will return a component for the given
itemGrid.addColumn(Renderer)
,
Grid.removeColumn(Column)
public Grid.Column<T> setHierarchyColumn(String propertyName)
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 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.
propertyName
- a target hierarchy column property namepublic Grid.Column<T> setHierarchyColumn(String propertyName, ValueProvider<T,?> valueProvider)
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 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.
propertyName
- a target hierarchy column property namevalueProvider
- optional value providerpublic Grid.Column<T> setColumns(String hierarchyPropertyName, ValueProvider<T,?> valueProvider, Collection<String> propertyNames)
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 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.
hierarchyPropertyName
- a target hierarchy column property namevalueProvider
- optional value providerpropertyNames
- set of properties to create columns for. Including given
hierarchyPropertyNamepublic void expand(T... items)
If an item is currently expanded, does nothing. If an item does not have any children, does nothing.
items
- the items to expandpublic void expand(Collection<T> items)
If an item is currently expanded, does nothing. If an item does not have any children, does nothing.
items
- the items to expandprotected void expand(Collection<T> items, boolean userOriginated)
items
- the items to expanduserOriginated
- true
if a ExpandEvent
triggered by this
operation is user originated, false
otherwise.public void expandRecursively(Stream<T> items, int 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.
items
- the items to expand recursivelydepth
- the maximum depth of recursionpublic void expandRecursively(Collection<T> items, int 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.
items
- the items to expand recursivelydepth
- the maximum depth of recursionpublic void collapse(T... items)
For items that are already collapsed, does nothing.
items
- the collection of items to collapsepublic void collapse(Collection<T> items)
For items that are already collapsed, does nothing.
items
- the collection of items to collapseprotected void collapse(Collection<T> items, boolean userOriginated)
items
- the collection of items to collapseuserOriginated
- true
if a CollapseEvent
triggered by this
operation is user originated, false
otherwise.public void collapseRecursively(Stream<T> items, int 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.
items
- the items to collapse recursivelydepth
- the maximum depth of recursionpublic void collapseRecursively(Collection<T> items, int 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.
items
- the items to collapse recursivelydepth
- the maximum depth of recursionprotected Collection<T> getItemsWithChildrenRecursively(Collection<T> items, int 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.
items
- the items to expand recursivelydepth
- the maximum depth of recursionpublic boolean isExpanded(T item)
item
- the item to checkpublic HierarchicalDataCommunicator<T> getDataCommunicator()
Grid
getDataCommunicator
in class Grid<T>
null
public HierarchicalDataProvider<T,SerializablePredicate<T>> getDataProvider()
Grid
getDataProvider
in interface HasHierarchicalDataProvider<T>
getDataProvider
in class Grid<T>
null
Copyright © 2023. All rights reserved.