2011-07-09 39 views
2

我在我的入口點創建了一個CellList。 (將選中的單元格的顏色從藍色更改爲深黑色)CellList GWT CSS樣式

據我所知,我只需要重寫cellList的樣式,選擇所選的樣式並更改背景顏色(然後保存在module.css中)

所以這就是我所用的。

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

但每次我選擇一個單元格時,它仍然顯示舊顏色(#628cd5)。我做錯了什麼?

噢,是的,我清理了項目並重新啓動了服務器 - 並清除了瀏覽器緩存。

回答

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

    // .... 

}