I have created Table using vaadin.Now i want to set font size for particular column content in that table.Is it possible to set font size for particular column in that table?. If so please give me idea to set the font size.If u can provide me some code snippet.
Yes, with CellStyleGenarators. Check 5.12.2 in the Book of Vaadin. You basically do a
if(propertyId.equals(yourColumnName)) {
return "someStyleName";
}
else {
return null;
}
inside your Table.CellStyleGenerator() and set the style for your text in css.
using CellStyleGenerator
simpleTable.setCellStyleGenerator(new Table.CellStyleGenerator() { @Override public String getStyle(Table components, Object itemId, Object columnId) { int row = Integer.valueOf((String)itemId); if (row%2 == 0) return "grey"; else return "white"; } });
ColumnGenerator as it is described in How to get started with Vaadin: Table Styling
public class DescriptionColumnGenerator implements Table.ColumnGenerator {
@Override public Object generateCell(Table components, Object itemId, Object columnId) { int row = Integer.valueOf((String)itemId); Property prop = components.getItem(itemId).getItemProperty(columnId); Label label = new Label("desc: " + prop.getValue()); if (row%2 != 0) { label.addStyleName("column-description"); label.addStyleName("column-" + (String) columnId); } return label; } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With