Comments (4)
Tried with the following on Vaadin 14.4.8:
List<Person> items = new ArrayList<>();
// 1. instantiate grid and columns
Grid<Person> grid;
grid = new Grid<>();
grid.addColumn(item -> items.indexOf(item) + 1).setHeader("#");
grid.addColumn(Person::getEmail).setHeader("A").setKey("TEST");
grid.addColumn(Person::getFirstName).setHeader("B");
grid.addColumn(Person::getLastName).setHeader("C");
items.add(new Person(100, "Lucas", "Kane", 68, new Address("12080", "Washington"), "127-942-237"));
grid.setItems(items);
// 2. hide column
grid.getColumnByKey("TEST").setVisible(false);
// 3. add item to list
items.add(new Person(101, "Foo", "Bar", 53, new Address("12080", "Washington"), "127-942-237"));
// 4. refresh data provider
grid.getDataProvider().refreshAll();
add(grid);
Please provide an example project that the issue can be reproduced with.
from vaadin-grid.
Maybe the issue is when each step is broken down into actions from the user. In a fresh project, the following is giving me the exception. When you run the project, as a user on the UI, click the buttons from top to bottom. After the last button you will see the exception.
package org.vaadin.spring.tutorial;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.Route;
import java.util.ArrayList;
import java.util.List;
@Route
public class MainView extends VerticalLayout { // implements LocaleChangeObserver {
private Button btn1;
private Button btn2;
private Button btn3;
private Grid<Person> grid;
private List<Person> items = new ArrayList<>();
public MainView() {
btn1 = new Button("1. Add record", event -> {
addRecord();
btn1.setEnabled(false);
btn2.setEnabled(true);
btn3.setEnabled(false);
});
btn2 = new Button("2. Hide column 'A'", event -> {
grid.getColumnByKey("TEST").setVisible(false);
btn1.setEnabled(false);
btn2.setEnabled(false);
btn3.setEnabled(true);
});
btn2.setEnabled(false);
btn3 = new Button("3. Add record", event -> addRecord());
btn3.setEnabled(false);
grid = new Grid<>();
grid.addColumn(item -> items.indexOf(item)+1).setHeader("#");
grid.addColumn(Person::getFirstName).setHeader("A").setKey("TEST");
grid.addColumn(Person::getLastName).setHeader("B");
grid.addColumn(Person::getHaircut).setHeader("C");
grid.setItems(items);
add(btn1, btn2, btn3, grid);
}
private void addRecord() {
items.add(new Person("ted", "johnson", "bowlcut"));
grid.getDataProvider().refreshAll();
}
public class Person {
private String firstName;
private String lastName;
private String haircut;
public Person(String firstName, String lastName, String haircut) {
this.firstName = firstName;
this.lastName = lastName;
this.haircut = haircut;
}
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 getHaircut() {
return haircut;
}
public void setHaircut(String haircut) {
this.haircut = haircut;
}
}
}
from vaadin-grid.
@sosa-vaadin I have a similar issue with _setFooterTemplateOrRenderer.
More precisely: I'm getting a client-side exception when doing the following sequence: instantiate grid with a footer row, hide a column, update some grid properties (incl. text in the footer row of active columns), and then call refreshAll on the data provider.
An easy fix probably would be to add the same additional check as in #2144 && !this.hidden
to _setFooterTemplateOrRenderer
in vaadin-grid-column.js
from vaadin-grid.
@arenk Please open a ticket in https://www.github.com/vaadin/web-components so it will get done. After that, you can open a PR yourself and we'll take a look at it.
from vaadin-grid.
Related Issues (20)
- TypeScript generics to allow declaring GridItem type HOT 1
- vaadin grid current row highlight issue HOT 1
- TreeGrid regression since 14.4.3 HOT 9
- Ellipses in selection column HOT 4
- 18.0.3 breaks grid in grid details HOT 1
- setItemDetailsRenderer in Vaadin 14.4.5 produce (TypeError) : $0.$connector HOT 1
- Clearing grid filtering is not working HOT 2
- Scrolling in a grid on iOS (Safari, Chrome) impossible HOT 6
- Grid.getDataProvider().refreshAll() length must not be negative HOT 1
- Grid with item details opened- after item deleting and grid refreshing attribute 'details-opened' stays in a row
- Grid: AppendFooterRow produces an Error when appending more than 8 FooterRows HOT 1
- TreeGrid regression regarding garbled scrolling output HOT 3
- Vaadin-grid horizontal scroll issue in iOS 14 HOT 15
- Getter for grid's selection mode HOT 2
- Sorting indicators are not preserved when column order is changed using Grid#setColumnOrder
- Grid throws UnsupportedOperationException if buffered editor is open during PreserveOnRefresh HOT 4
- Grid column width is calculated wrong on Safari 14.0.3 (Big Sur) HOT 6
- GridPro "out of memory" on Firefox facing 1k Strings HOT 3
- TypeError: Cannot read properties of undefined (reading '_content') in Chrome Browser HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vaadin-grid.