I am looking for some way to add a checkBox at heaher of checkColumnConfig.
Below is the 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;
}
});
And I have tried to add a checkBox by using setWidget() method as below
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");
However, the checkBox will not work correctly, such as not check/uncheck while clicking it, and/or always get true value on its Event.OnChange.
Any help is appreciated.
Aucun commentaire:
Enregistrer un commentaire