Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append custom style to a GWT CellTable (in this case all cells)

I have a case where I want to append

white-space: nowrap;

to the style of each cell in my CellTable. Currently it applies to all tables, but it would be nice to know both have to apply it for a specific CellTable, and all CellTables.

like image 220
l3dx Avatar asked Jun 17 '11 12:06

l3dx


1 Answers

CellTables have their own CssResource. To override this style applied to all cells in a cellTable, create a new css file :

/* Incremental changes from CellTable.css */ 
.cellTableCell {
  white-space: nowrap;
}

Then create your own CellTable.Resources interface :

public interface TableResources extends CellTable.Resources {

    /**
       * The styles applied to the table.
       */
    interface TableStyle extends CellTable.Style {
    }

    @Override
    @Source({ CellTable.Style.DEFAULT_CSS, "MyOwnCellTableStyleSheet.css" })
    TableStyle cellTableStyle();

}

Finally, when creating your cellTable, use the constructor that lets you specify which Resources to use

CellTable<Object> myCellTable = new CellTable<Object>(15, GWT.create(TableResources.class));

For a working example, look at the Expenses sample provided in the GWT SDK.

like image 134
jonasr Avatar answered Nov 12 '22 12:11

jonasr