Search code examples
gwtlayoutuser-interfacedatagridflowpanel

Datagrid inside FlowPanel is not visible- GWT


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?


Solution

  • 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.