1

I am displaying books information in the Vaadin grid. It is displayed almost as I wanted it, but still having problem that I don't know how to solve. Therefore I would appreciate advice(s). Here is how I am creating this grid:

private void createBooksTable() {
    this.booksTable = new Grid<>();
    this.booksTable.setWidth("100%");
    this.yearRenderer = new ActionYearRenderer();
    this.booksTable.addColumn(this.yearRenderer).setWidth("8%");
    this.booksTable.addColumn(new NewTagRenderer()).setWidth("3%");
    this.booksTable.addColumn(new AuthorListRenderer()).setWidth("18%");
    this.booksTable.addColumn(new TitleRenderer()).setWidth("50%");
    this.booksTable.addColumn(new RatingRenderer()).setWidth("4%");
    this.booksTable.addColumn(new ReaderRatingRenderer()).setWidth("3%");
    this.booksTable.addColumn(new StatusRenderer()).setWidth("5%");
    this.booksTable.setItemDetailsRenderer(new BookDetailsRenderer());
}

As you can see, the sum of all width is less than 100%, but last column is going outside of the screen and being cut. Maybe it happening because of some default column padding, as I see quite a gap between columns. I didn't find a way to fit all columns into the screen. If you know the way to do it, please tell me.

Gary Greenberg
  • 1,084
  • 8
  • 14

1 Answers1

0

I would recommend set the widest column to grow the remaining space instead of setting definitive percent width.

this.booksTable.addColumn(new TitleRenderer()).setFlexGrow(1);
Tatu Lund
  • 9,949
  • 1
  • 12
  • 26
  • I followed your recommendation and last column did fit into the screen, but the size of the title column was reduced significantly and the title itself was cut for many books. Also gap between first three columns increased. – Gary Greenberg Dec 12 '22 at 06:26
  • If you have multiselect enabled you need to take multiselect column into account. – Tatu Lund Dec 14 '22 at 04:30
  • No, I do not have multiselect enabled. But why setting definitive percent with doesn't work? It does work with plain old HTML. – Gary Greenberg Dec 15 '22 at 01:18