Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client side update that's not working correctly after sorting #10427

Closed
ZaoszRichard opened this issue Dec 11, 2017 · 5 comments
Closed

Client side update that's not working correctly after sorting #10427

ZaoszRichard opened this issue Dec 11, 2017 · 5 comments
Milestone

Comments

@ZaoszRichard
Copy link

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:

@Override
protected void init(VaadinRequest vaadinRequest) {

List<Test> 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<Test> 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);
}
}
@ZaoszRichard
Copy link
Author

Vaadin version is: 8.1.7

@rdavono
Copy link

rdavono commented Mar 26, 2018

This is still not working in Vaadin 8.3.2. As soon as a component in a grid is hidden with setVisible(false) sorting/filtering/scrolling does not work anymore.

I slightly changed the demo, maybe the problem is more obvious now. When you initially show this UI only even rows have a visible button in the component column. After some scrolling every row has a button, odd rows have completely wrong buttons.

@Theme("mytheme")
public class MyUI extends UI {
   @Override
   protected void init(VaadinRequest vaadinRequest) {
      List<Test> entries = IntStream.range(1, 100)
         .mapToObj(Test::new)
         .collect(toList());

      Grid<Test> grid = new Grid<>();

      grid.addColumn(Test::getName).setCaption("Name");

      grid.addComponentColumn(source -> {
         Button btn = new Button(source.getName());

         // !!!!!!!!!
         btn.setVisible(source.getNo() % 2 == 0);

         return btn;
      }).setCaption("Button");

      grid.setItems(entries);
      this.setContent(grid);
   }

   static class Test  {
      private final int    no;
      private final String name;

      public Test(int no) {
         this.no = no;
         this.name = String.format("User %02d", no);
      }

      public int getNo() {
         return this.no;
      }

      public String getName() {
         return name;
      }
   }

   @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
   @VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
   public static class MyUIServlet extends VaadinServlet {
   }
}

@stale
Copy link

stale bot commented Aug 23, 2018

Hello there!

We are sorry that this issue hasn't progressed lately. We are prioritizing issues by severity and the number of customers we expect are experiencing this and haven't gotten around to fix this issue yet.

There are a couple of things you could help to get things rolling on this issue (this is an automated message, so expect that some of these are already in use):

  • Check if the issue is still valid for the latest version. There are dozens of duplicates in our issue tracker, so it is possible that the issue is already tackled. If it appears to be fixed, close the issue, otherwise report to the issue that it is still valid.
  • Provide more details how to reproduce the issue.
  • Explain why it is important to get this issue fixed and politely draw others attention to it e.g. via the forum or social media.
  • Add a reduced test case about the issue, so it is easier for somebody to start working on a solution.
  • Try fixing the issue yourself and create a pull request that contains the test case and/or a fix for it. Handling the pull requests is the top priority for the core team.
  • If the issue is clearly a bug, use the Warranty in your Vaadin subscription to raise its priority.

Thanks again for your contributions! Even though we haven't been able to get this issue fixed, we hope you to report your findings and enhancement ideas in the future too!

@stale stale bot added the Stale Stale bot label label Aug 23, 2018
@rdavono
Copy link

rdavono commented May 27, 2019

I cannot reproduce this error with Vaadin 8.8.2 anymore

@stale stale bot removed the Stale Stale bot label label May 27, 2019
@TatuLund
Copy link
Contributor

Thanks for reporting, it is possible, that this is fixed as by product of this pull request #11566

@ZheSun88 ZheSun88 added this to the Invalid milestone Jun 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants