Francois1
(Francois Regnaut)
January 6, 2010, 11:20am
1
Hi,
I would like to change the default property alignement in a table (which is LEFT)
In fact I would like to set this depending on the type of the property
Texts : to the left, numerics to the right, and center the rest…
Where to set this code ?
It tried to override the formatPropertyValue of the Table.class. But here, I can’t change the alignment.
What would be the best place to set this ?
Thanks
Matti
(Matti Tahvonen)
January 7, 2010, 8:19am
2
Hi!
There is an api for it:
t.setColumnAlignment("propertyId",
Table.ALIGN_RIGHT);
cheers,
matti
Francois1
(Francois Regnaut)
January 7, 2010, 8:34am
3
I know this API… But I would like that my table do it for me…
I started to extends the vaadin Table, and I 'm searching where to set this alignment (using the API), so when I will set the containerDatasource, the table will automatically align each column/property depending on its type…
Artur
(Artur Signell)
January 7, 2010, 8:47am
4
I know this API… But I would like that my table do it for me…
I started to extends the vaadin Table, and I 'm searching where to set this alignment (using the API), so when I will set the containerDatasource, the table will automatically align each column/property depending on its type…
Just a quick thought:
You could possible extend Table and override
public String getColumnAlignment(Object propertyId) {
final String a = columnAlignments.get(propertyId);
return a == null ? ALIGN_LEFT : a;
}
And return another default than ALIGN_LEFT or check something from the data source e.g. using getContainerDataSource().getType(propertyId)
Emanuele
(Emanuele Turella)
March 9, 2011, 2:10pm
6
@Override
public String getColumnAlignment(Object propertyId) {
Class<?> t = getContainerDataSource().getType(propertyId);
if (t == Double.class)
return Table.ALIGN_RIGHT;
if (t == Date.class)
return Table.ALIGN_CENTER;
return super.getColumnAlignment(propertyId);
}