TreeGrid data updates don't work

We are using Vaadin 13.0.11. We have trouble with data updates in a TreeGrid component (Pro subscription). Imagine the following tree structure:

+   +-C
+   +-D

We do not use a custom data provider. Instead, we set the items using multiple calls of treegrid.getTreeData().addItem(). In the following, let treedata refer to treegrid.getTreeData().

Everything works fine and the tree structure is shown as desired.

However, now we want to replace the children of B with new children. For this, we first call treedata.removeItem() for both C and D. Then, we call treedata.addItems(B, collectionWithNewChildren).

Afterwards, we tried two different approaches to refresh the TreeGrid. Both variants didn’t work.

First try: call treegrid.getDataProvider().refreshAll(). After this, the updated TreeGrid is shown correctly only if node B is not too low in the grid. If B has a low position and you scroll down, at some point suddenly all content disappears except the first node.

Second try: call treegrid.getDataProvider().refreshItem(B). After this, the subtree of B is NOT updated. You still see the old children.

Our current workaround is to reinitialize the grid completely. This leads to a terrible UX. Actually, we need to use the second approach because that is the only one that updates the grid in-place without resetting the scroll position.

So, our question is: Is this a bug in TreeGrid or do we have to do anything differently?

Hi Tim. I think what you are facing is related to the missing feature of “deep refresh” for TreeGrid. Here is the related issue