我正在寻找一些方法来在checkColumnConfig的heaher处添加一个checkBox
以下是checkColumnConfig:
CheckColumnConfig checkColumn = new CheckColumnConfig("isReport",
"Report", 25);
checkColumn.setAlignment(HorizontalAlignment.CENTER);
checkColumn.setRenderer(new GridCellRenderer<GuiReportNode>() {
@Override
public CheckBox render(final GuiReportNode model, String property, ColumnData config,
int rowIndex, int colIndex, ListStore<GuiReportNode> store,
Grid<GuiReportNode> grid) {
final String name = model.get("name");
final CheckBox checkBox = new CheckBox();
if (name.equals("System")) {
checkBox.setValue(true);
checkBox.disable();
} else {
final boolean isReport = model.get("isReport");
if (isReport) {
checkBox.setValue(true);
}
checkBox.addListener(Events.OnChange, new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent be) {
for(CheckBox tmp : historicalCheckBoxList)
{
if(tmp.getData("name").equals(name))
{
if(checkBox.getValue()) tmp.enable();
else tmp.disable();
break;
}
}
editGridStore.findModel(model).setIsReport(checkBox.getValue());
}
});
}
checkBox.setData("name", name);
reportCheckBoxList.add(checkBox);
return checkBox;
}
});
我尝试使用setWidget()方法添加一个checkBox,如下所示
final CheckBox tmpBox = new CheckBox();
tmpBox.setValue(true);
tmpBox.setBoxLabel("Report");
tmpBox.addListener(Events.OnChange, new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent be) {
logger("Click " + tmpBox.getValue().toString());
}
});
LayoutContainer lc = new LayoutContainer();
lc.setLayout(new FitLayout());
lc.add(tmpBox);
checkColumn.setSortable(false);
checkColumn.setWidget(lc, "Report");
但是,checkBox将无法正常工作,例如在单击时不检查/取消选中,和/或始终在其Event.OnChange上获得true值。
感谢任何帮助。