简体   繁体   中英

Append custom style to a widget extending GWT CellTable

I implemented my own widget by extending GWT CellTable. I am now looking to remove the 2px table borders that GWT has by default on the table. Here is the structure of my custom widget:

public class CustomWidget extends CellTable {

public CustomWidget (DataModel _dataModel, Updater _updater) { ... } }

I saw a related answer here on StackOveflow and followed those steps. However, I extend CellTable to create my own widget, which is different from the original post where an instance of a basic CellTable is created. The step I need help with is how to tweak the following line of code, given in the other post, to provide a new Resources class to my custom CellTable widget:

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

where TableResources extends CellTable.Resources.

One way to do this is to define a css class (somewhere you make sure that it loads in your target page):

.myBorderlessCell
{
    border: 0;
}

and then in your java code:

CustomWidget cw = new CustomWidget(...);
cw.addStyleName("myBorderlessCell");

this overrides border attribute of your widget.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM