Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Editable Grid: impossible to reliably invoke editItem() on init?
we're trying to get unbuffered editable Grid to work for our use case (version 7.6.3), but there seems to be a serious problem with it (well, one of the many...).
Our design calls for the first row to be immediately editable upon Grid initialization. However, calling editItem() immediately on a newly instanced grid sometimes works correctly and sometimes it breaks. By "it breaks" I mean the the editor fields are stuck with a width of 100px and don't update if the Grid takes "long enough" to fetch the first page of data (about 30-50 rows from a database using JPA with ~10 columns, in our case).
What happens is that editor fields - managed by Grid$Editor - take their width from the body of the grid - which is managed by Escalator. The column widths start at 100px and then there seems to be async code that "fixes" the column width on Escalator.onLoad(). However, Escalator.onLoad() ignores the editor and doesn't notify anyone about what it's doing, so during the first request we've got Grid creating the editor when the columns might or might not have been updated from 100px to their final size. (Not sure why Grid starts with that 100 px wide columns - it's pretty ugly to see the browser render those columns first and then enlarge them almost immediately.)
This looks like a race between two pieces of asyncronous JS: if Escalator finishes first (e.g. few columns/rows of data), then the editor is sized correctly upon rendering the Grid. If Grid$Editor finishes first (lots of data/columns), you've got all the editor fields collapsed to the default 100 px with no way to fix it unless the user manually clicks on another row.
Am I correct in describing what's happening? Is there no way to know when we can finally trust the column sizes and make sure the editor uses them?
And most importantly, is there a workaround that can be applied only by extending the existing widgets instead of ripping off 25K+ lines of code from the framework to maintain a separate version of Grid/Escalator? Perhaps one can make an extension?
Advice on how to workaround this would be greatly appreciated.