How to set the font size for a specific column in a Vaadin table?

I created a table using vaadin.Now, I want to set the font size for the specific contents of the column in this table. Can I set the font size for a specific column in this table ?. If yes, please give me an idea to set the font size. If you can provide me a piece of code.

+4
source share
3 answers

Yes, with CellStyleGenarators. Check out 5.12.2 in the book of Vaadin . You basically do

if(propertyId.equals(yourColumnName)) { return "someStyleName"; } else { return null; } 

inside your Table.CellStyleGenerator () and set the style for your text in css.

+8
source

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 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; } } 
+1
source

You can add a style name for this column.

0
source

Source: https://habr.com/ru/post/1302951/


All Articles