How do I style a gwt 2.1 CellTables headers?

rapadura picture rapadura · Nov 16, 2010 · Viewed 11.1k times · Source

I see nothing in the documentation except a reference to include some "CssResource" and get it with ClientBundle, but how do I exactly override the tbody and th of a CellTable?

Is this possible?

Answer

Hilbrand Bouwkamp picture Hilbrand Bouwkamp · Nov 16, 2010

Create an interface:

  interface TableResources extends CellTable.Resources {
    @Source({CellTable.Style.DEFAULT_CSS, "<your css file>.css"})
    TableStyle cellTableStyle();
  }

  interface TableStyle extends CellTable.Style {
  }

and initialize the cell table:

    CellTable.Resources resources = GWT.create(TableResources.class);
    table = new CellTable<SomeProxy>(rowSize, resources);

In the cellview.client package you can find the default gwt css files. Yo use those as your starting point. In the "<your css file>.css" put you specific style changes.

You can also set colum style (on the col element):

table.addColumnStyleName(colNumer, "some_css_style_name");

or better use css resource name instead of string "some_css_style_name".