Minimal Table height

What is the best way to make a table’s height dynamic in relation to the amount of rows in the table? I have a table that should be just big enough to fit all the data in it. It should also update its size when rows are added or deleted.

Best solution I’ve found so far is doing this always when you add or delete a row:

table.setPageLength(table.getContainerDataSource().getItemIds().size());

That’s not really pretty, but it works. I just would want to check that there’s not a more elegant solution that only changes the appearance of the table without having the call the server side of the component all the time. I was hoping that setting an undefined height with table.setHeight(null) would have done it, but it was a no go.

Isn’t setPageLength(0) switches the table into non-paging mode, so it will redner all rows without a scroller ?

Ooh. You’re absolutely right. That was what I was looking after. Thanks!