Clear grid


I have the following problem when clearing a grid.

After clicking a button, the grid should be cleared and rerendered. But when I do

for(Column column: grid.getColumns()) {

//... some code to add new columns and setItems..

//And then sorting the grid via
for (Column<Row> column : grid.getColumns()) {

Then, the following error-message appears in the browser:
TypeError: Cannot read property ‘parentNode’ of null.

What is going on here?

Instead of clearing the Grid, why not create a new one?

Thanks Olli, this is a good workaround.

Hmm, maybe you can help me again.

I Have a vertial Layout in which i have 3 horizontal Layouts each with a grid.
If I added the first horizontal Layout, everything is fine. But when I add a grid to the second Horizontal Layout, display it, there are scrollbars showing up. The vertical Scrollbar is ok, but how i can avoid the horizontal scrollbar?

I guess you’ll need to control the widths of the component so they won’t take as much horizontal space.

I set the 3-sub views width by


but this doesn’t fix my problem.

I fixed the problem by using the annotation @BodySize(). :slight_smile: The problem was the width 100vw in the body element.

Nice! Maybe this thread will help other people who encounter the same issue.