【问题标题】:GWT CellBrowser with CompositeCell带有 CompositeCell 的 GWT CellBrowser
【发布时间】:2012-03-04 02:54:11
【问题描述】:

我正在尝试构建如下所示的 CellBrowser。

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

问题是,我无法获得上述代码中给出的标题(数学科学)。标题来自不同的对象,我的 CompositeCell(CheckBox 和 TextCell)似乎期待/适用于所有项目。

基本上,我正在尝试在 CellBrowser 中构建列表,其中一些具有(CheckBox 和 TextCell),而其中一些只有(TextCell)。

请指教。

【问题讨论】:

    标签: gwt uibinder composite-controls cellbrowser


    【解决方案1】:

    您必须覆盖您的CompositeCellCheckBoxCell 的渲染方法。像这样的:

    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) 中的标志,也可以将标志直接传递给单元。

    您也可以修改 CheckBoxCell 的渲染方法:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-05
      • 2014-08-04
      • 1970-01-01
      相关资源
      最近更新 更多