Frage

I have a Datagrid which I am placing inside a FlowPanel. However, this datagrid is not visible unless I explicitly set its size by doing datagrid.setSize("100%", "250px").

I want the datagrid's width to be 100% but I want its height to change according to the number of rows in it. When is only do datagrid.setWidth("100%") the datagrid is still not visible. How do overcome this problem?

War es hilfreich?

Lösung

DataGrid needs to either have an explicit size or be put into a LayoutPanel and you must ensure an unbroken chain of LayoutPanels up to the RoutLayoutPanel.

Here are some possible solutions:

  • Use CellTable instead of DataGrid.
  • Calculate the required height (numer of rows * row height) and available size (getOffsetHeight on the FlowPanel) and manually set the height accordingly.

Andere Tipps

Set the width and height both to 100%. If that stretches things, try setting the height of rows to a specific number (from CSS, preferably), that should create rows of a fixed sized, with potentially empty space under it.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top