2012-03-02 3 views
0

아래 주어진대로 CellBrowser를 빌드하려고합니다.GWT CellBrowser with CompositeCell

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

문제는, 나는 위의 코드에 주어진 제목 (수학과학)을 얻을 수 없습니다입니다. 제목은 다른 Object에서 가져온 것으로, CompositeCell (CheckBox 및 TextCell)은 모든 항목을 예상/적용한 것 같습니다.

기본적으로 CellBrowser에서 일부는 (CheckBox 및 TextCell), 일부는 (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의 렌더링 방법을 수정할 수 있습니다