Repository navigation
feat: Introduce flattened hierarchy format - #22040
Merged
Merged
Conversation
Contributor
vursen
force-pushed
the
flat-hierarchy-api
branch
2 times, most recently
from
August 18, 2025 07:07
179ed14 to
3ec2cd1
Compare
vursen
changed the base branch from
main
to
refactor/flattening-data-in-tree-grid
August 18, 2025 07:07
1 task done
vursen
force-pushed
the
flat-hierarchy-api
branch
from
August 18, 2025 15:48
0fb19ba to
0b894ba
Compare
vursen
marked this pull request as ready for review
August 19, 2025 09:32
vursen
commented
Aug 19, 2025
| * scrolling quickly. | ||
| * </ul> | ||
| */ | ||
| NESTED, |
Contributor
Author
There was a problem hiding this comment.
The alternative could be RECURSIVE
Contributor
There was a problem hiding this comment.
RECURSIVE describes the hierarchy format a bit better since data providers are supposed to fetch tree branch recursively.
And just FLAT for the other one.
Contributor
There was a problem hiding this comment.
I changed my mind about this change after realizing it's too much focused on edge case of fetching the whole tree at once.
tltv
previously approved these changes
Aug 22, 2025
wip wip wip wip wip rename isFlatHierarchy to getHierarchyFormat add missing details wip wip
vursen
force-pushed
the
flat-hierarchy-api
branch
from
August 22, 2025 13:05
e325042 to
7b39cfb
Compare
|
tltv
approved these changes
Aug 25, 2025
Collaborator
|
This ticket/PR has been released with Vaadin 25.0.0-alpha8. |
Copilot AI
pushed a commit
that referenced
this pull request
Oct 1, 2025
The PR introduces a new getHierarchyFormat() method to HierarchicalDataProvider. It can be configured to return either HierarchyFormat#NESTED (default) or HierarchyFormat#FLATTENED (new). The selected format defines in what way the data provider returns hierarchical data and how HierarchicalDataCommunicator should fetch and render it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
The PR introduces a new
getHierarchyFormat()method to HierarchicalDataProvider. It can be configured to return eitherHierarchyFormat#NESTED(default) orHierarchyFormat#FLATTENED(new). The selected format defines in what way the data provider returns hierarchical data and how HierarchicalDataCommunicator should fetch and render it.Nested Hierarchy Format (default)
The nested hierarchy format refers to a data provider implementation in which each expanded parent's children are fetched via a separate request, on demand:
Every request to the data provider returns a paginated list that contains only the direct children of the
HierarchicalQuery#getParent(). The component decides when to request deeper levels and how much to load based on the current viewport and the expansion state of items, storing this lazy loaded hierarchy state in memory.Example:
Pros:
Cons:
HierarchicalDataProvider#refreshAll()which resets the cached hierarchy state.Flattened Hierarchy Format (new)
The flattened hierarchy format refers to a data provider implementation that returns the entire subtree of the
HierarchicalQuery#getParent()in a single, flattened, paginated list:The list contains all expanded descendants, arranged in depth-first order: starting from the parent, then its children and their
descendants, before the next sibling. The component delegates hierarchy construction entirely to the data provider by supplying a
HierarchicalQuerywhere:HierarchicalQuery#getOffset()points to the start of the requested range across all flattened descendantsHierarchicalQuery#getLimit()specifies the number of items to returnHierarchicalQuery#getExpandedItemIds()contains the set of expanded item IDsThe flattened format also requires the data provider to implement
HierarchicalDataProvider#getDepth(T), which the component uses to make items appear as a hierarchy by applying visual indentation.Example:
Pros:
refreshAll()avoids unexpected scroll jumps by refetching the total tree size and retaining the size of expanded items whose nested structure hasn't changed.Cons:
Depends on
Fixes #21880, #21878
Type of change