Joel
Joel

Reputation: 2688

GWT DataGrid Sizing

I have a DataGrid which I want to grow vertically (height) as I add rows to it. The widget to add to the grid should be directly underneath the DataGrid. How do I do this?

The answer to "GWT DataGrid automatic height" was too obscure (if it was one). I tried placing the DataGrid in ResizeLayoutPanel, but it only shows the datagrid header.

Upvotes: 5

Views: 2573

Answers (1)

Michael Laffargue
Michael Laffargue

Reputation: 10314

For those still struggling with CellTable (auto-height, pager always under the last line) and DataGrid (fixed header but height should be fixed and the pager will stay at the same place even if you got one line of data).

Don't forget they extend the same class : AbstractCellTable

So you can adapt your code easily (Note TableType is just an enum I created):

if (tableType == TableType.CELLTABLE) {
      // CellTable
      CustomTableWidgetCellTableResource resource = GWT.create(CustomTableWidgetCellTableResource.class);
      table = new CellTable<T>(10, resource);
    } else {
      // DataGrid
      CustomTableWidgetDataGridResource resource = GWT.create(CustomTableWidgetDataGridResource.class);
      table = new DataGrid<T>(10, resource);
      table.setHeight("470px"); // Default height
    }

Upvotes: 1

Related Questions