I already posted this in the github, but there is no any answer yet, hope someone else could help me.
Exception is thrown in client if we put the Grid into dialog and callled “setDataProvider()” “select” twice
when open the dialog again, fetch the data from DB and set the DataProvider, it should work.
because we often to add some data in some page and go back to another page to open the dialog, that time we should refresh the page content, it should work
Currently It will throw exception in browser
Live Demo
Steps to reproduce
@Route(value = "hello", layout = MainView.class)
@PageTitle("Hello World")
@CssImport("./styles/views/helloworld/hello-world-view.css")
@RouteAlias(value = "", layout = MainView.class)
public class HelloWorldView extends HorizontalLayout {
private Button sayHello;
Dialog dialog = new Dialog();
List<String> list = new ArrayList<>();
private Grid<String> grid = new Grid<String>();
public HelloWorldView() {
list.add("aa");
list.add("bb");
list.add("cc");
grid.setWidth("300px");
grid.setHeight("300px");
grid.addColumn(String::toString);
dialog.add(grid);
setId("hello-world-view");
sayHello = new Button("Say hello");
add(sayHello);
sayHello.addClickListener(e -> {
// we will fetch the data from db in my actual environment, here I just create one list.
grid.setDataProvider(DataProvider.fromStream(list.stream()));
Random random = new Random();
grid.select(list.get(random.nextInt(3)));
//first time, it will work, everything looks good. But when you call it again ,it will throw exception.
// this is just one demo, it is different with my actual environment. this code just proves the issue.
//and it already blocked our development process. hope it could be resolved soon. thanks.
dialog.open();
});
}
}