2012-03-05 8 views
0

gwtデータグリッドの選択色をグローバルに変更する方法はありますか? 私はメインのアプリ-cssファイルに次のCSS形式を追加しました:悲しいことに、私の変更は効果がなかった http://code.google.com/intl/de-DE/webtoolkit/doc/latest/DevGuideUiCss.htmlGWT - データグリッド選択色

.dataGridSelectedRow { 
    background: #1EDA17; 
    color: white; 
    height: auto; 
    overflow: auto; 
} 

また、私は次のリンクを見てきました。 setStyleName()コールが欠落していますか?

答えて

0

GWTがclean.cssで上書きするので、カスタムCSSは機能しません。 FIREBUGまたは他のツールを使用する場合は、それを認識するかもしれません。解決策は簡単です。 を追加!重要カスタムCSS

.dataGridSelectedRow { 
    background: #1EDA17 !important; 
    color: white !important; 
    height: auto !important; 
    overflow: auto !important; 
} 
+0

感謝。 .gwt-Button {font-size:150%!important;} の例が動作していますが、 .dataGridSelectedRow { 背景:#1EDA17! 色:白!重要; 身長:auto!important; オーバーフロー:auto!important; } は効果がありませんでした。私はまた、いくつかの他のデータグリッドCSSプロパティを試したが効果もなかった。データグリッドはすべてを無視するようです。 – user1165474

1

データグリッドで選択された行の書式カスタムCSSを設定する別の方法もあると影響を受けていないそれぞれの行に。 DataGrid.Resourcesを拡張するカスタムインターフェイスを作成する必要があります。このインターフェースでは、メソッドdataGridStyle()と@Source annotaionをカスタムCSSファイルに置くべきです。

import com.google.gwt.user.cellview.client.DataGrid; 
import com.google.gwt.user.cellview.client.DataGrid.Resources; 

public interface CustomDataGridResources extends Resources { 

public interface CustomDataGridResources extends Resources { 
    @Source({DataGrid.Style.DEFAULT_CSS, "resources/CustomDataGridStyles.css"}) 
    CustomStyle dataGridStyle(); 

    interface CustomStyle extends DataGrid.Style { 
    } 
} 

あなただけ選択した行のスタイルを変更したい場合は、CSSファイルのみが含まれます:たとえば

.dataGridSelectedRow { 
    background: #1EDA17; 
    color: white; 
    height: auto; 
    overflow: auto; 
} 

しかし、私はまたhowered行のカーソルを変更することを好む:

.dataGridHoveredRow { 
    cursor: pointer; 
    cursor: hand; 
} 

similar discussionもご覧ください。

あなたのDataGridにカスタムスタイルを適用するために、あなたはグリッドのコンストラクタリソースは、(私の場合CustomDataGridResources)をカスタムインタフェースを実装するインスタンスです

public DataGrid(int pageSize, Resources resources, ProvidesKey<T> keyProvider) 

を使用することができます。あなたのヒントの

DataGrid.Resources customDataGridResources = GWT.create(CustomDataGridResources.class) 
関連する問題