我试图创建一个包含复选框项列表的scrollPanel。我的主要问题是使用CheckboxCell构建一个CellList。这是一个导致编译时错误的片段。
CheckboxCell testCheckBox = new CheckboxCell();
CellList<String> cellList = new CellList<String>(testCheckBox);
错误消息:构造函数CellList(CheckboxCell)未定义。
如果这是错误的构造函数,那么正确的方法是什么?
答案 0 :(得分:2)
尝试将CellList的类型更改为布尔值。
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中:)答案 1 :(得分:1)
你可以试试这样的东西。您将需要一些额外的本机代码来处理“检查”事件。
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);