TreeGrid does not show content until i sort column

Hello,
i am quite new to vaadin and vaadin flow, so be patient.

It is quite complicated to create a minimal example and the problem is quite urgent so i hope we can fix this without…
I try to create a TreeGrid and populate it with a data provider derived from AbstractHierarchicalDataProvider<InfoTreeItemBaseInterface, Void>
I have designed the page in the designer and added my component with the TreeGrid incorporated, so it looks something like this:

<vaadin-vertical-layout class="item" style="width: 100%; height: 100%;">
  <vaadin-grid id="grid" size="height:100%; width:100%"></vaadin-grid>
 </vaadin-vertical-layout>

The data i try to visualize are 5 nodes where each has between 1 and 3 hierarchies and between 1 and 3 subnodes

Now, on loading the page the dataprovider is called and if i debug the code i can see, that the data is gathered from the data povider, but no data is shown in the grid. The headers are visible, but no content. If i press one sort button in the header, the grid is redrawn and the data shown as expected. So I have to press the sort button one time to show the data. After this most works as expected. I can extend nodes by hand (not programmatically, but this is a problem for a other, non so urgent topic)

Is there something obvious i miss? Do i have to call some redraw after populating? Any idea where the error can be?
If the problem is deeper in my logic as a workaround i would accept to manually trigger the sort button from code, but how do i do that?

Many thanks in advance!

I forget to add: Vaadin 13

Hi Valentin!

The size attribute is for setting the total number of items in the data provider, not the physical dimensions of the grid. Try removing it, as it’s not needed at all when setting the data provider from the server side :slight_smile:

Dohhh… Of course… this should have been “style” not “size”…
Sometimes you get blind by your own code.

Fixed and now it works!

Thank you very much!

I do have the same problem, though I fill the TreeGrid programmatically.
The TreeGrid lists only the column headers. but nothing else. Only when I click the sort icon on the hierarchy column, data appears.

It doesn’t matter if I work with value providers or add items to the TreeData directly - they only appear after clicking on the sorting icon

Any ideas?

I managed to solve it myself by adding the following line AFTER I filled the grid with items:

treegrid.sort(Arrays.asList(new GridSortOrder<Contact>(treegrid.getColumns().get(0), SortDirection.ASCENDING)));

I assume triggers the same mechanics as would clicking on the sorting arrows do.