Vaadin Table with IndexedContainer column size issue

I extended IndexedContainer to be used with a paginated Table. The Table is set with undefined size (so does the upline hierarchy) so when it is first rendered, i.e. page 1, all columns have their width computed dynamically, which is fine.

When switching to another page the custom IndexedContainer reloads a new set of items and these are successfully picked up and rendered by the Table. However, the Table does not adjust the column widths according to the new set of items. Basically, the column widths are exactly the ones computed dynamically for page 1…

I’ve been trying to fix this by manually:

setColumnWidth(…, -1) on all columns
setSizeUndefined(), again, on the Table
setWidth(-1, …) on the Table
marksAsDirty(Recursive)() on both the Table and UI
but nothing worked as expected.

Any thoughts would be appreciated. Thanks!

(Originally posted at http://stackoverflow.com/questions/18816969/vaadin-table-with-indexedcontainer-column-size-issue)

Hi,

you’re right, the dynamic column widths are only calculated at the first render. To overcome this issue, there is an experimental feature in Table. To enable it, you will need to extend Table (in this case PagedTable) and set the protected internal field
alwaysRecalculateColumnWidths
to true. This should make the Table recalculate column widths each time a different set of rows is rendered.

-tepi

Hi Teppo,

Your suggestion seems to work. Thank you very much for your help!