简体   繁体   中英

gwt CheckBoxCell within CellList

Im trying to create a scrollPanel that holds a list of checkbox item. My main problem is constructing a CellList with CheckboxCell. Here is a snippet of whats causing the compile time error.

CheckboxCell testCheckBox = new CheckboxCell();

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

Error Message: The constructor CellList(CheckboxCell) is undefined.

If this is the wrong constructor, what is the correct way?

Try changing the type of CellList to Boolean.

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

update:

More examples on various cells (this is combined checkbox + picture, but you might want to replace picture with text):

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

It's little trickier, but this showcase contains also sources so might want to dive into them.

PS: Lazier solution is not to use Cell Widgets and make own (extends Composite) combo/label and place it in say FlexTable :)

You can try something like that. You are going to need some extra native code to handle the "check" event.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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