Mr. Xymon
Mr. Xymon

Reputation: 1053

How to align text of selected CellTable columns in GWT?

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.

enter image description here

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

Answers (3)

eon
eon

Reputation: 1938

Well, what you had is almost right. This works for me, without css: myColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);

Upvotes: 8

Gnik
Gnik

Reputation: 7426

unitPriceColumn.setCellStyleNames("alignRight");

totalAmountColumn.setCellStyleNames("alignRight");

Where alignRight is the name of your CSS.

.alignRight {text-align:right}

Upvotes: 1

Krzysztof Zielinski
Krzysztof Zielinski

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

Related Questions