Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I style a gwt 2.1 CellTables headers?

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?

like image 262
rapadura Avatar asked Nov 16 '10 13:11

rapadura


3 Answers

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".

like image 193
Hilbrand Bouwkamp Avatar answered Oct 24 '22 06:10

Hilbrand Bouwkamp


Just for the fun of it I might add something I just had a headache with... if you change cellTableStyle(); with something else it breaks... no warning or error, the CSS just does not appear as I thought it would. Dont know where this is documented, but I found it out after alot of fiddeling trying to find out why some CSS was correct and some not..

like image 29
terje Avatar answered Oct 24 '22 04:10

terje


For some reason my cellTable.addColumnStyleName(colNumber, "cssStyle") just won't work. According to FireBug it doesn't add the style no matter what (if the style was incorrect, it at least could have added it to the classes attribute of the th-element...). Maybe it's because I am redrawing the columns, but it'S weird nevertheless.

like image 2
Igor Avatar answered Oct 24 '22 06:10

Igor