Reputation: 1053
I want to right-align numeric values in a CellTable. I already tried looking for ways to assign a style name for selected columns so I could align it with CSS but still couldn't figure out.
I also tried this but didn't work,
itemPriceColumn.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT);
According to the GWT documentation, the new horizontal alignment will apply the next time the table is rendered... and I don't know yet what parameters I have to pass since it is required by render() method.
So I'm hoping for answers that would involve CSS.
Upvotes: 2
Views: 5239
Reputation: 1938
Well, what you had is almost right. This works for me, without css: myColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
Upvotes: 8
Reputation: 7426
unitPriceColumn.setCellStyleNames("alignRight");
totalAmountColumn.setCellStyleNames("alignRight");
Where alignRight
is the name of your CSS.
.alignRight {text-align:right}
Upvotes: 1
Reputation: 400
Option 1: Use float:right on the parent element ( in the CellTable).
Option 2: Create your own TextCell and implement render method to generate something like this:
<div style="width:100%; text-align:center;"> your value </div>
Upvotes: 0