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

Javascript error when display and select a line of a grid #4438

Closed
bisam-rd opened this issue Jul 26, 2018 · 2 comments
Closed

Javascript error when display and select a line of a grid #4438

bisam-rd opened this issue Jul 26, 2018 · 2 comments
Assignees
Labels
BFP Bugfix priority, also known as Warranty bug

Comments

@bisam-rd
Copy link

Scenario:

  • Open a screen with a hidden grid and a button
  • Click on the button: the button should display the grid and select the first line
    => javascript error. The grid is displayed, but the first line is not selected.

Code example:

import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.theme.Theme;
import com.vaadin.flow.theme.lumo.Lumo;

import java.util.Arrays;
import java.util.List;

@Route("table")
@Theme(Lumo.class)
public class TableOnButtonView extends Div {

    public TableOnButtonView() {
        List<Person> people = Arrays.asList(
                new Person("Nicolaus Copernicus", 1543),
                new Person("Galileo Galilei", 1564),
                new Person("Johannes Kepler", 1571));

        Grid<Person> grid = new Grid<>();
        grid.setItems(people);
        grid.addColumn(Person::getName).setHeader("Name");
        grid.addColumn(person -> Integer.toString(person.getYearOfBirth()))
            .setHeader("Year of birth");

        grid.setVisible(false);
        add(grid);
        Button click = new Button("click");
        click.addClickListener(e -> {
            grid.setVisible(true);
            grid.getSelectionModel().select(people.get(0));
        });
        add(click);
    }

    class Person {
        private String name;
        private int yearOfBirth;

        public Person(String name, int yearOfBirth) {
            this.name = name;
            this.yearOfBirth = yearOfBirth;
        }

        int getYearOfBirth() {
            return yearOfBirth;
        }

        String getName() {
            return name;
        }

    }
}
@bisam-rd bisam-rd changed the title Javascript error on display and select a grid Javascript error when display and select a line of a grid Jul 26, 2018
@pekam pekam added the bug label Jul 31, 2018
@pekam pekam added this to the 1.0 Maintenance milestone Jul 31, 2018
@pekam
Copy link
Contributor

pekam commented Jul 31, 2018

Might be related to #4444

Trying to call gridConnector.js before it has been initialized:
TypeError: Cannot read property 'updateData' of undefined

@pleku pleku added the BFP Bugfix priority, also known as Warranty label Aug 1, 2018
@denis-anisimov denis-anisimov self-assigned this Aug 1, 2018
@denis-anisimov
Copy link
Contributor

This is a duplicate for #4444.
The IT test that verifies it : vaadin/vaadin-grid-flow#291

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BFP Bugfix priority, also known as Warranty bug
Projects
None yet
Development

No branches or pull requests

4 participants