Question

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.

Was it helpful?

Solution

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

OTHER TIPS

unitPriceColumn.setCellStyleNames("alignRight");

totalAmountColumn.setCellStyleNames("alignRight");

Where alignRight is the name of your CSS.

.alignRight {text-align:right}

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top