CellList GWT CSS样式

时间:2011-07-09 17:04:18

标签: css gwt

我在入口点创建了一个CellList。现在我想要它的样式。(将所选单元格的颜色从蓝色变为深黑色)

据我所知,我只需要覆盖cellList的样式,选择所选的样式并更改背景颜色(然后保存在module.css中)

所以这就是我的意思。

@sprite .cellListSelectedItem {
/*gwt-image: 'cellListSelectedBackground';*/
/*BEFORE : background-color: #628cd5;*/
background-color: #2D2D2D;
color: white;
height: auto;
overflow: visible;
}

然而,每当我选择一个单元格时,它仍然显示旧颜色(#628cd5)。我做错了什么?

哦,是的,我清理了项目并重新启动了服务器 - 并清除了浏览器缓存。

1 个答案:

答案 0 :(得分:4)

你需要告诉GWT使用新的样式 - 简单地将它们添加到你的模块CSS文件是不够的:

table = new CellTable<FooType>(12,
    CellTableResources.INSTANCE, keyProvider);

CellTableResources.INSTANCE应该是扩展CellTable资源包的资源包实例。类似的东西:

import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.resources.client.ImageResource.ImageOptions;
import com.google.gwt.resources.client.ImageResource.RepeatStyle;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.CellTable.Style;

public interface CellTableResources extends CellTable.Resources {

  public static CellTableResources INSTANCE = GWT.create(CellTableResources.class);

  @Source("footer_bg.png")
  @ImageOptions(repeatStyle = RepeatStyle.Both, flipRtl = true)
  ImageResource cellTableFooterBackground();

  @Source("header.png")
  @ImageOptions(repeatStyle = RepeatStyle.Horizontal, flipRtl = true)
  ImageResource cellTableHeaderBackground();

  @Source("table_head_bg_left.png")
  @ImageOptions(repeatStyle = RepeatStyle.None, flipRtl = true)
  ImageResource cellTableHeaderFirstColumnBackground();

  @Source("table_head_bg_right.png")
  @ImageOptions(repeatStyle = RepeatStyle.None, flipRtl = true)
  ImageResource cellTableHeaderLastColumnBackground();

  @Source(CellTableStyle.DEFAULT_CSS)
  Style cellTableStyle();
}

当然,对于CellTableStyle来说也是同样的事情:

import com.google.gwt.user.cellview.client.CellTable;

public interface CellTableStyle extends CellTable.Style {

   String DEFAULT_CSS = "path/to/your/new/CellTable.css";

   String cellTableCell();

   // ....

}