0

I've tried both Grid.setUndefined() and Grid.setHeight("-1px") and neither works. They should both be doing the same but if my grid only has say 3 items then the bottom of the grid is empty and the height is significantly taller than 3 rows.

Stephane Grenier
  • 15,527
  • 38
  • 117
  • 192

3 Answers3

3

Try setHeightByRows method (Java doc).

Steffen Harbich
  • 2,639
  • 2
  • 37
  • 71
1

Here is my proposition for workaround:

grid.getDataProvider().addDataProviderListener( dataProviderEvent ->
                grid.setHeightByRows( grid.getDataProvider().size( new Query() ) ) 
);
Dawid Fieluba
  • 1,271
  • 14
  • 34
  • Your solution work great, But you should check the size of your datas. It should be more than zero rows, otherwise it will return error. – Mankeomorakort Jan 28 '19 at 10:42
1

Set the grid HeightMode to UNDEFINED:

grid.setHeightMode(HeightMode.UNDEFINED);
rjdkolb
  • 10,377
  • 11
  • 69
  • 89
MarinaL
  • 11
  • 1
  • 4
    Welcome to Stack Overflow! While this code could solve the problem, it is best to add elaboration and explain how it works for people who might not understand this piece of code. – Papershine Apr 25 '18 at 10:24