17

我有一个想追加的案例

white-space: nowrap;

我的 CellTable 中每个单元格的样式。目前它适用于所有表格,但很高兴知道两者都必须将其应用于特定的 CellTable 和所有 CellTables。

4

2 回答 2

31

CellTables 有自己的CssResource。要覆盖应用于 cellTable 中所有单元格的此样式,请创建一个新的 css 文件:

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

然后创建自己的 CellTable.Resources 接口:

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();

}

最后,在创建 cellTable 时,使用可让您指定要使用的资源的构造函数

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

有关工作示例,请查看 GWT SDK 中提供的费用示例。

于 2011-06-17T14:19:19.547 回答
0

或者你可以用简单的方法做到这一点:

CellTable<YourObj> yourTable = new CellTable<YourObj>();
yourTable.getElement().getStyle().setWhiteSpace(WhiteSpace.NOWRAP);

没有 css 文件,没有奇怪的样板代码。

于 2016-12-06T15:33:24.493 回答