Set vaadin table height to match content

I use CustomLayout in my project to separate the user interface object and its style.

I have some problems with tables.

I define a div and want the table height to be set to the height of the div.

What is the best way?

I thought:

table.setsizeFull() ;
table.setPageLength(0);

in the code, but the result is not the one I want. I want the table to have a size in div sizes, both inside and without elements inside.

Someone tell me?

+5
source share
1 answer

: , , . , , . , .

, :

  • setHeight() .
  • setPageLength(), - .
  • requestRepaint() . , . , .

, , . , .

public class MyClass extends Table {

    public MyClass(...)
    {
        this.setWidth("100%"); // fill parent <td> width, allows draggable sizing.
        // note: do NOT setHeight().

        setupColumns(); // details not shown here
        setupBehavior(); // details not shown (listeners, etc)
        addDataToTable(); // details not shown

        adjustHeight();
    }

    // I also have a function to add rows to the table when 
        // a button is clicked.  That function calls adjustHeight() (shown below).

    public void adjustHeight()
    {
        this.setPageLength(this.getItemIds().size() + 1);
        this.requestRepaint();
    }
}

[EDIT/FOLLOW-UP] , , , setColumnExpandRatio() ( ). , -, (setColumnWidth()), , .

+8

All Articles