PageLength not changing table size

Within a single Window, I currently have a VerticalLayout that contains two components: a panel and a button. The panel contains a table which, by default, displays x rows of some data set, with a scrollbar present if the data set is larger than x items.

When the user clicks the button, I want the table to change its size from x to y, where y < x. I had thought this would be accomplished by simply calling table.setPageLength(y), but so far that hasn’t done anything. I have tried to do this by both setting the height of the window/layout/panel/table all to 100% and all to undefined, with no luck. It looks like it works temporarily (i.e., for a split second, only y rows are shown), but the table itself doesn’t change size and eventually x rows are made visible again.

Interestingly, I’ve been able to get the table to change size by overriding the size() method in my data container to conditionally return y when the button has been pressed. For example:

public int size() {
        int size;
    	if (!buttonPressed) {
    	    size = container.size();
    	} else {
            size = y;
        return size;

This hides all but y entries in the table, though (without a scrollbar), so that’s not the behavior I want.

Is it possible, then, to use pageLength to dynamically change the height of a table? Am I missing some key step, or is this just not the way page length was meant to be used?


Ouch, it seems you’ve stumbled upon a really old bug:
I’ll see if I can bump that to some upcoming milestone.

In the meantime, I think the workaround is to make a new table and replace the old one

layout.replaceComponent(oldTable, newTable);


Best Regards,