Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

TUTORIALVaadin lets you build secure, UX-first PWAs entirely in Java.
Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Calling javascript synchronously by Enver Haase, 3 weeks ago
Cell Clickable Renderer with vCheckBox widget
Hi,
Using this info from the book almost everything works fine, when I click an unchecked box, it turns checked and the checkbox.setText("X") sets the text, and when I uncheck the box, it does, but the text does not gets cleared checkbox.setText("") or checkbox.setText(null) don't work. please help me.
server side renderer
addClickListener(new RendererClickListener() {
/**
*
*/
private static final long serialVersionUID = 7908980496657581489L;
@Override
public void click(RendererClickEvent event) {
Grid grid = getParentGrid();
Object itemId = event.getItemId();
Object propertyId = event.getPropertyId();
Container.Indexed containerDataSource = grid.getContainerDataSource();
Property<String> itemProperty = containerDataSource.getItem(itemId).getItemProperty(propertyId);
grid.setImmediate(true);
logger.log(Level.INFO, "A itemProperty = " + itemProperty.getValue());
String[] vals = itemProperty.getValue().split("-");
if(vals[0].equals(getSession().getAttribute("user").toString())) {
itemProperty.setValue("0-");
} else if (vals[0].equals("0")) {
itemProperty.setValue(getSession().getAttribute("user").toString().concat("-").concat(getSession().getAttribute("user").toString()));
}
logger.log(Level.INFO, "B itemProperty = " + itemProperty.getValue());
}
});
client side renderer
VCheckBox chkBox;
@Override
public VCheckBox createWidget() {
VCheckBox b = GWT.create(VCheckBox.class);
b.addClickHandler(this);
b.setStylePrimaryName("v-checkbox");
b.setEnabled(false);
return b;
}
@Override
public void render(RendererCellReference cell, String usuario, VCheckBox checkBox) {
String[] usr = usuario.split("-");
chkBox = checkBox;
setbox(usr);
}
@Override
public void render(RendererCellReference cell, String data) {
String[] usr = data.split("-");
setbox(usr);
}
void setbox(String[] usr) {
chkBox.setText("");
chkBox.setTitle("");
chkBox.setValue(!usr[0].equals("0"), false);
if(chkBox.getValue()) {
chkBox.setText(usr[0]);
chkBox.setTitle(usr[1]);
}
}
Last updated on
You cannot reply to this thread.