繁体   English   中英

在CellList中的gwt CheckBoxCell

[英]gwt CheckBoxCell within CellList

我正在尝试创建一个包含复选框项目列表的scrollPanel。 我的主要问题是用CheckboxCell构造一个CellList。 这是导致编译时间错误的代码片段。

CheckboxCell testCheckBox = new CheckboxCell();

CellList<String> cellList = new CellList<String>(testCheckBox);

错误消息:构造函数CellList(CheckboxCell)未定义。

如果这是错误的构造函数,正确的方法是什么?

尝试将CellList的类型更改为Boolean。

CheckboxCell testCheckBox = new CheckboxCell();
CellList<Boolean> cellList = new CellList<Boolean>(testCheckBox);

更新:

有关各种单元格的更多示例(这是复选框+图片的组合,但是您可能希望将图片替换为文本):

http://gwt.google.com/samples/Showcase/Showcase.html#!CwCellTree

有点棘手,但是此展示柜还包含资源,因此可能想深入研究它们。

PS:Lazier解决方案是不使用Cell Widgets并制作自己的(扩展Composite)组合/标签并将其放在FlexTable中:)

您可以尝试类似的方法。 您将需要一些额外的本机代码来处理“检查”事件。

public class StyleCell extends AbstractCell<Style> {
@Override
public void render(Context context, Style row, SafeHtmlBuilder sb) {
    if (row == null) {
        return;
    }
    sb.appendHtmlConstant("<INPUT TYPE=CHECKBOX NAME='property'>" + row.getProperty() + "</INPUT>");
}

}

StyleCell styleCell = new StyleCell();
CellList<Style> styleList = new CellList<Style>(styleCell);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM