I have a layout bug in GridPro that perhaps is related to either event chaining or timing.
It occurs after creating new columns, trying a recalculateColumnWidths() doesn’t help if done in the same event.
I have a Select component that, during a valueChange event, triggers new columns creation and layout in the GridPro grid. After creating new columns I call recalculateColumnWidths() in the same valueChange event from the Select. The result is a GridPro with empty space between the rows, but when I either click a button or let a timer fire, then the call to recalculateColumnWidths() works fine. Here is a bit of code to give an idea:
startYear.addValueChangeListener(evt -> {
itemSubView.resetGrid(makeParams());
itemSubView.genericGrid.recalculateColumnWidths(); // Doesn't work
timer.setStartTime(3);
timer.start();
});
refreshBtn.addClickListener(evt -> {
itemSubView.genericGrid.recalculateColumnWidths(); // Now it works
});
timer.addTimerEndEvent(ev-> {
System.out.println("tick");
itemSubView.genericGrid.recalculateColumnWidths(); // Now it works
});
The test is a lot of code so you have to go here and download the code to recreate it, use the “GridPro Generator Test” menu and try changing the Select values:
Is it me or is there some kind of race condition in GridPro?
Here is how it look when it fails:
Compare that to the picture in the repo or download and try the demo.