0
votes

I am trying to align a column in my cell table to the right. Therefore I use the "setHorizontalAlignment" of my column object. The resulting cell is actually rendered with the "align=right", but it is not aligned to the right because the cell contains another div that fills the complete cell.

Is this a bug in GWT or am I doing it wrong?

TextColumn<String> myColumn = new TextColumn<String>() {
    @Override
    public String getValue(String myObj) {
        return myObj;
    }
};
myColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
myCellTable.addColumn(myColumn, "anyColumnName");

enter image description here

I know I can also align it right via CSS, but I hope, I can get this approach working because it seems to be the cleaner solution.

2

2 Answers

0
votes

You can do it using css and Column#setCellStyleNames().

Sample code:

myColumn.setCellStyleNames("rightAlign");

css:

.rightAlign{
    text-align: right;
}

Note: change css as per your requirement

0
votes

I have the same code, and it renders the same way - with a div element that takes 100% of the width. And the text inside this cell is displayed aligned to the right - as it should. So this is not a GWT bug.

There is another style in your CSS that interferes here. Most likely, you have something like this in your CSS:

td {
    text-align: left;
}