Skip to content

JS error occurs when grid columns are re-created #1981

@onuridrisoglu

Description

@onuridrisoglu

I have a use case, where grid columns are dynamically created each time user makes some selection in the view.
Normally it works fine, but when the columns are re-created, if also a new row should be added, then the following error appears: Cannot read property '__getRowModel' of undefined

It seems to be because of vaadin-grid-column's grid property is not set.

Here is a sample code to reproduce the issue:

private Grid<Bean> grid;
private List<Bean> beans;

public SampleGridTest() {
	grid = new Grid<>();
	beans = new ArrayList<>();
	beans.add(new Bean("Hello"));
	Button addButton = new Button("add");
	addButton.addClickListener(evt -> {
		beans.add(new Bean("Hello"));
		grid.removeAllColumns();
		grid.addColumn(Bean::getValue).setHeader("Bean");
		grid.setDataProvider(DataProvider.ofCollection(beans));
	});
	grid.addColumn(Bean::getValue).setHeader("Bean");
	grid.setDataProvider(DataProvider.ofCollection(beans));
	add(grid, addButton);
}

Vaadin version : 13.0.1
Browser : Chrome Version 72

Metadata

Metadata

Assignees

Labels

BFPBug fix prioritised by a customerbugSomething isn't workingcomponentsflow

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions