2 つの質問があります。
質問1。この質問 (投稿のタイトル) は、ここからの最初の回答に対する @Cataclysm からの最後のコメントから直接取得されます。
dataGrid = new DataGrid<T>(pageSize, resource)
、 UIBinder の CSS リソースを設定する方法は?
UIBinder で定義された DataGrid のスタイルを設定しようとしています:
<g:south size="400">
<c:DataGrid ui:field="documentDataTable" />
</g:south>
この ClientBundle インターフェイス コードを使用すると、次のようになります。
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.cellview.client.DataGrid.Resources;
import com.google.gwt.user.cellview.client.DataGrid.Style;
/**
* Resources = "DataGrid.Resources"
* Style = "DataGrid.Style"
*
* http://federico.defaveri.org/?p=157
* https://code.google.com/p/google-web-toolkit/issues/detail?id=6144#c3
* https://stackoverflow.com/questions/7394151/datagrid-celltable-styling-frustration-overriding-row-styles/7395175#comment26605442_7395175
*/
public interface CustomDataGridResource extends Resources {
@Source({Style.DEFAULT_CSS, "css/CDD_DataGridStyle.css"})
CustomStyle dataGridStyle();
interface CustomStyle extends Style {
String dataGridHeader();
}
}
そしてCDD_DataGridStyle.css
:
.dataGridHeader {
background-color: purple;
}
これらの参照を使用して:
- DataGrid / CellTable のスタイリングのフラストレーション -- 行スタイルのオーバーライド
- http://www.gwtproject.org/javadoc/latest/com/google/gwt/user/cellview/client/DataGrid.html
- http://www.gwtproject.org/javadoc/latest/com/google/gwt/user/cellview/client/DataGrid.Style.html
- http://crazygui.wordpress.com/2011/11/01/how-to-skin-a-gwt-celltable/
- https://code.google.com/p/google-web-toolkit/issues/detail?id=6144#c3
リファレンス 1 への回答から私が理解したことから、このリソース スタイル シートは、通常のクライアント バンドルのように「注入」されるのではなく、プログラムによってインスタンス化されたデータ グリッドにリソースとして渡される必要があります。
「新しくスタイルを設定したデータグリッドを構築するには、次のことを行う必要があります。
DataGridResource resource = GWT.create(DataGridResource.class); dataGrid = new DataGrid<T>(pageSize, resource)"
奇妙なことに、私は への参照を持っていますが、リソースを「設定」するためのAPI ドキュメントDataGrid @UIField
にはメソッドがないようです (したがって、 UIBinder で既に定義されていることに関するこの質問に対する最後のコメントの再投稿としての質問- DataGrid/CellTable のスタイリングのフラストレーション - 行スタイルのオーバーライド)。DataGrid.java
DataGrid
質問 #2: と の違いは何DataGrid
ですかCellTable
? どちらが正しい実装構文ですか?
(参照 2)の Google GWT API ドキュメントが、プログラムDataGrid.java
によるインスタンス化のみを詳述しているのはなぜですか? 拡張することはCellTable
理解していますが、API サンプル コードで7 つのコンストラクターのいずれも使用しないのはなぜですか?DataGrid.java
AbstractCellTable.java
DataGrid
さらに紛らわしいことに、参考文献 4 と 5 では、クライアント バンドル インターフェイスを拡張する必要があることが示唆されていますがCellTable.Resources
、参考文献 1 では拡張が推奨されていDataGrid.Resources
ます (このリンクも参照してください: http://federico.defaveri.org/?p=157 )。
リファレンス 5の最後の投稿 (#13) の「After」コード例を適用しようとしましたが、ネストされたインターフェイスがエラーをスローしました。
public interface NxoCellTableResources extends CellTable.Resources {
public interface NormalStyle extends CellTable.Style {}
@Source({ CellTable.Style.DEFAULT_CSS, "NxoCellTable.css" })
public NormalStyle cellTableStyle();
}
public interface NxoCellTableThinResources extends CellTable.Resources {
public interface ThinStyle extends CellTable.Style {}
@Source({ CellTable.Style.DEFAULT_CSS, "NxoCellTable.css", "NxoCellTableThin.css" })
public ThinStyle cellTableStyle();
}
要約すると、UIBinder で定義された DataGrid 内のすべての要素をスタイル設定する最も簡単な方法を探しています。使用するリソース構文 (DataGrid と CellTable) の明確な説明があります。UIBinder から参照を削除し、必要に応じてプログラムでビューに挿入することもできます。よろしくお願いします!