Vaadin 8.1.7 Grid with ComponentRenderer

Hi Experts,

First of all sorry my poor english.
I have a grid in lazy mode (using data provider) and it has a column contains CheckBox somtimes is visible, sometimse is not, dependent on data.
When it show the check box columns showing fine but after sorting another column the checkboxes showing mixing.

Where it not should be appear it showing after sorting other column. Data is correct. Here is my code:

Grid.Column col = getGrid().addColumn(( EventStorage source ) -> { if ( source.getModel().hasDelegate()) { source.setVisibleCheckBox(Boolean.FALSE); source.setCheckBoxEnable(Boolean.FALSE); } else { source.setVisibleCheckBox(Boolean.TRUE); source.setCheckBoxEnable(Boolean.TRUE); } return source.getCheckBox(); }, new ComponentRenderer()); Please give me advice.

Regards,
Richard

That kind of sounds like a bug. Might be that there’s some client side update that’s not working correctly after sorting. If you can create a minimal reproducable example where the component fails to refresh correctly after sorting, you should create a ticket about it.

-Olli

Hey Olli,

I don’t know where to open a ticket, but this was my test code for his problem, seems like some are updated but others aren’t.
I guess it has something to do with the setVisibleCheckBox method, because commenting it out solves it too.

[code]
@Override
protected void init(VaadinRequest vaadinRequest) {

List entries = new ArrayList<>();

for(int i = 0; i < 100; i++) {
CheckBox temp = new CheckBox("User "+i);
temp.setValue(i%3==0);
Test dummy = new Test("User "+i, i%20, temp);
entries.add(dummy);
}

DataProvider dataProvider = new ListDataProvider<>(entries);

Grid grid = new Grid();
grid.setDataProvider(dataProvider);

grid.addColumn(Test::getName).setCaption(“Name”);
grid.addColumn(Test::getAge).setCaption(“Age”);

grid.addColumn(source → {
if (source.getAge() > 15) {
source.setVisibleCheckBox(Boolean.FALSE);
source.setCheckBoxEnable(Boolean.FALSE);
} else {
source.setVisibleCheckBox(Boolean.TRUE);
source.setCheckBoxEnable(Boolean.TRUE);
}
return source.getCheckBox();
}, new ComponentRenderer()).setCaption(“CheckBox”);

this.setContent(grid);
}

public class Test {

private String name;

private int age;

private CheckBox checkBox;

private Test(String name, int age, CheckBox checkBox) {
this.name = name;
this.age = age;
this.checkBox = checkBox;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

public CheckBox getCheckBox() {
return checkBox;
}

public void setCheckBox(CheckBox checkBox) {
this.checkBox = checkBox;
}

public void setVisibleCheckBox(Boolean bool) {
checkBox.setVisible(bool);
}

public void setCheckBoxEnable(Boolean bool) {
checkBox.setEnabled(bool);
}
}
[/code]Also I don’t now how to properly format my code in the forum code tag :open_mouth:

Hope this will help.

-Michael

Hello Richard,

CheckBox box = source.getCheckBox();
if ( source.getModel().hasDelegate()) {
source.setVisibileCheckBox(Boolean.False);
...
} else {
...
}
return box;

maybe try this, that’s what worked for me.

Thanks @Michael Rzehulka
I opened this issue: https://github.com/vaadin/framework/issues/10427

@Olli Tietäväinen
Do you have any workaround for this?

You can open a ticket at
https://github.com/vaadin/framework/issues

-Olli