How can I wrap long text in a grid cell?
I tried the following:
/*
* The grid that will hold the products
*/
Grid<Product> productGrid = new Grid<>();
productGrid.addColumn(TemplateRenderer.<Product>of("<div><img src = '[[item.thumbnailUrl]
]'></img></div>")
.withProperty("thumbnailUrl", Product::getThumbnailImage)).setHeader("Image").setFlexGrow(0).setWidth("10em");
productGrid.addColumn(Product::getName).setHeader("Name");
productGrid.addColumn(Product::getSalePrice).setHeader("Price").setFlexGrow(0);
productGrid.addColumn(
TemplateRenderer.<Product>of("<div style='text-align:right'>[[item.description]
]</div>")
.withProperty("description", Product::getLongDescription))
.setHeader("Description").setFlexGrow(1);
productGrid.addComponentColumn(product->{
Label label = new Label(product.getLongDescription());
label.getStyle().set("text-align", "right");
return label;
}).setHeader("Description").setFlexGrow(1);
The last 2 cells are the same description column. I tried both labels and TemplateRenderer. I can change the label color, etc using the getStyle, but how to force it to wrap long text? Or am I going about it the wrong way?