2012-03-02 8 views
0

私は以下のようにCellBrowserを構築しようとしています。GWT CellBrowser with CompositeCell

Week 1 -> Mathematics 
Week 2 [] Algebra 
Week 3 [] Trigonometry 
      Science 
      [] Physics 
      [] Chemistry   

問題は、私は上記のコードで与えられる見出し(数学科学)を取得することはできませんよ、です。見出しは異なるObjectからのもので、私のCompositeCell(CheckBoxとTextCell)はすべてのアイテムを期待しているようです。

基本的には、(CheckBoxとTextCell)を持つCellBrowserでリストを作成しようとしていますが、その中には(TextCell)しかないものもあります。

お知らせください。

答えて

0

CompositeCellまたはCheckBoxCellのレンダリング方法をオーバーライドする必要があります。このようなもの:

public class MyCompositeCell extends CompositeCell<Course> 
{ 
    @Override 
    protected <X> void render(Context ctx,Course value, 
          SafeHtmlBuilder sb, HasCell<Course, X> hasCell) { 
    if (hasCell.getCell() instanceof CheckBoxCell && !value.hasCheckBox()) 
     return; 
    super.render(ctx,value, sb, hasCell); 
} 

機能hasCheckBox()は単なる例です。あなたのDTO(Course)のフラグにアクセスするか、フラグをセルに直接渡すことができます。

public class MyCheckBoxCell extends CheckBoxCell<Course> { 

    @Override 
    public void render(Context ctx,Transformation value, SafeHtmlBuilder sb) { 
     if (!value.hasCheckBox()) 
      return; 
     super.render(ctx,value, sb); 
    } 

また、あなたのCheckBoxCellのレンダリング方法を変更することができます