-
Notifications
You must be signed in to change notification settings - Fork 71
Closed
Labels
Description
Description
When setting some grouped columns visibility to false during the grid initialization, those columns still appear but without any data or title. This doesn't happen if later one calls setVisible(false), probably because the data has already been loaded.
Doing it inside @onAttach doesn't solve the problem but in a background thread does.
Expected outcome
Column that were setVisible(false) would be hidden
Actual outcome
They are 'ghost columns' instead - don't have any data but are there laying around
Minimal reproducible example
@Route("grouping-bug")
public class GridColumnGrouping {
private static final long serialVersionUID = 1L;
public GridColumnGrouping() {
super();
Grid<SamplePerson2> grid = new Grid<>(SamplePerson2.class);
Grid.Column<SamplePerson2> firstNameColumn = grid
.addColumn(SamplePerson2::getFirstName)
.setHeader("First name");
Grid.Column<SamplePerson2> lastNameColumn = grid.addColumn(SamplePerson2::getLastName)
.setHeader("Last name");
Grid.Column<SamplePerson2> streetColumn = grid
.addColumn(person -> person.getAddress().getStreet())
.setHeader("Street");
Grid.Column<SamplePerson2> cityColumn = grid
.addColumn(person -> person.getAddress().getCity())
.setHeader("City");
HeaderRow headerRow = grid.prependHeaderRow();
headerRow.join(firstNameColumn, lastNameColumn).setText("Name");
headerRow.join(streetColumn, cityColumn)
.setText("Address");
List<SamplePerson2> people = Arrays.asList(
new SamplePerson2("Harry", "Potter", new Address("Privet Drive", "London")),
new SamplePerson2("Ron", "Weasley", new Address("Howgarts", "Scotland")));
grid.setItems(people);
lastNameColumn.setVisible(false); //to comment out to try the btn1
Button btn1 = new Button("LATER DO.", clickEvent -> {
lastNameColumn.setVisible(!lastNameColumn.isVisible());
});
add(btn1, grid);
}
public class Address {
String street;
String city;
public String getStreet() { return street; }
public void setStreet(String street) { this.street = street; }
public String getCity() { return city; }
public void setCity(String city) { this.city = city; }
public Address(String s, String c) {
this.street = s;
this.city = c;
}
}
public class SamplePerson2 {
private String firstName;
private String lastName;
private String email;
private String phone;
private LocalDate dateOfBirth;
private String occupation;
private boolean important;
private Address address;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public LocalDate getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(LocalDate dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
public String getOccupation() {
return occupation;
}
public void setOccupation(String occupation) {
this.occupation = occupation;
}
public boolean isImportant() {
return important;
}
public void setImportant(boolean important) {
this.important = important;
}
public Address getAddress() { return address; }
public void setAddress(Address address) { this.address = address; }
public SamplePerson2() { }
public SamplePerson2(String firstName, String lastName, LocalDate dateOfBirth) {
this.firstName = firstName;
this.lastName = lastName;
this.dateOfBirth = dateOfBirth;
}
public SamplePerson2(String firstName, String lastName, Address address) {
this.firstName = firstName;
this.lastName = lastName;
this.address = address;
}
}
}
Steps to reproduce
Clear steps describing how to reproduce the issue.
- Add a Grid component to a page.
- Add 2 or more columns inside a group.
- Set one of the columns visibility to false when initializing the grid
- Go to the browser and check for the existence of a ghost column where the hidden column should be
- Don't set it hidden during the grid initialization, but instead via button click.
- Go to the browser, load the grid and click the button - now it works.
Environment
- V14/V23