GridScrollExtension Add-on
Simple extension to get, set and restore Grid scroll position in pixels and couple of other helpers.
Features
Remember scroll position in TabSheet
Grid doesn't yet have server side getters and setters for scroll position. This extension adds those. In addition that it is able to cache the latest known scroll position. The main motivation for writing this add-on is to make Grid maintain its scroll position during Tab changes when used inside the TabSheet layout component. See demo application how it works.
Get actual column widths
There is also also getColumnWidth(..) method to get actual column widths of the Grid.
Compensate Column resizing side effects
Use getColumnResizeCompensationMode(ColumnResizeCompensationMode.RESIZE_GRID) method to get actual column widths of the Grid and setAutoResizeWidth(..) to Grid to automatically adjust width according to column widths. If automatic mode is not wanted or there is need to force Grid to resize due corner cases adjustGridWidth() API can be used.
Use getColumnResizeCompensationMode(ColumnResizeCompensationMode.RESIZE_COLUMN) to auto adjust the last Column to occupy the remaining space (if any).
See also: https://github.com/vaadin/framework/issues/10638
Get actual size of Grid
getWidth(), getHeight() get actual width and height of Grid
Events
Events: GridRenderedEvent, GridResizedEvent, GridScrolledEvent and GridColumnsResizedEvent
There are corresponding addXXXListener methods. GridRenderedEvent is fired when initial column calculation is ready (real column widths are available after this). Other events should be useful also in various special cases.
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
Version 2.5.1
- Fix: Column widths should be reported also when ColumnResizeCompensationMode is NONE.
- Released
- 2021-08-11
- Maturity
- BETA
- License
- Apache License 2.0
Compatibility
- Framework
- Vaadin 8.10
- Vaadin 7.7+ in 1.0.0
- Vaadin 7.6+ in 1.1.1
- Vaadin 8.0+ in 2.0.0
- Browser
- N/A
GridScrollExtension Add-on - Vaadin Add-on Directory
Simple extension to get, set and restore Grid scroll position in pixels and couple of other helpers.Issue Tracker
Source Code
GridScrollExtension Add-on version 1.0.0
First version for Vaadin7, (version 2.0.0 is for Vaadin8). I have tested this one only with 7.7.x, but it could work with earlier versions too.
GridScrollExtension Add-on version 2.0.0
Fixed issue in pom.xml
GridScrollExtension Add-on version 2.0.1
### Version 2.0.1
- Fixing issue #2, Server side position was off sync after setPosition(..)
- Updated demo
GridScrollExtension Add-on version 1.0.1
### Version 1.0.1
- Backporting fix to issue #2 from 2.0.1: Server side position was off sync after setPosition(..)
- Updated the demo
GridScrollExtension Add-on version 2.1.0
### Version 2.1.0
- Adding getColumnWidth(..) to get actual width of a given column
GridScrollExtension Add-on version 2.1.1
### Version 2.1.1
- Adding setAutoResizeWidth(..) for Grid to automatically adjust width according to column widths.
GridScrollExtension Add-on version 1.1.1
### Version 1.1.1
- Added getColumnWidth(..) to get actual width of given column
- Added setAutoResizeWidth(..) to Grid automatically adjust width according to column widths.
GridScrollExtension Add-on version 2.2.0
### Version 2.2.0
- Adding events: GridRenderedEvent, GridResizedEvent, GridScrolledEvent and GridColumnsResizedEvent
- Added adjustGridWidth() API to force Grid resize according to column widths
- Added getWidth(), getHeight() get actual width and height of Grid (see issue #4)
- Fixed a bug: Extension did not work with hidden columns properly
- Fixed a bug: Vertical scroll bar adjustment was not correctly implemented
GridScrollExtension Add-on version 2.2.1
### Version 2.2.1
- Added workaround for Grid getting resized after sorting issue
GridScrollExtension Add-on version 2.2.2
### Version 2.2.2
- Fix: Size adjustment after sorting should be applied only when setAutoResizeWidth(true)
- Fix: Scroll bar adjustment needs to be handled differently on IE11/Edge
GridScrollExtension Add-on version 2.3.0
### Version 2.3.0
- Added ColumnResizeCompensationMode to choose between resizing Grid and resizing last column to compensate resizing of columns.
GridScrollExtension Add-on version 2.3.1
### Version 2.3.1
- ColumnResizeCompensationMode.RESIZE_COLUMN is now applied to fill the empty space also when Grid is resized
GridScrollExtension Add-on version 2.3.2
Version 2.3.2
- Fixing issues with compensation used when Column.setMaximumWidth(..) used. Works as partial workaround for some generic Grid Column.setMaximumWidth(..) bugs
GridScrollExtension Add-on version 2.3.3
### Version 2.3.3
- Improved JavaDocs
- Improved type safety
- added setRestorePosition(..) to workaround issue #5
GridScrollExtension Add-on version 2.3.4
### Version 2.3.4
- Fixing typo in method set/getColumnResizeCompensationMode name
- Improved JavaDocs
GridScrollExtension Add-on version 2.3.5
### Version 2.3.5
- Improved workaround to overcome issues with maximum widths of the columns, also fixes the issue #10
- Added getColumn() to GridColumnsResizedEvent
GridScrollExtension Add-on version 2.4.0
### Version 2.4.0
- Added support for hidden columns
GridScrollExtension Add-on version 2.4.1
### Version 2.4.1
- Fixing possible issue with undefined column widths
GridScrollExtension Add-on version 2.4.2
### Version 2.4.2
- Added a method to disable widths guard feature, GridScrollExtension#setWidthGuardDisabled(boolean)
GridScrollExtension Add-on version 2.4.3
### Version 2.4.3
- Fixed bug with hidden columns
- Made delayed column snapping thread safe
GridScrollExtension Add-on version 2.5.0
### Version 2.5.0
- Improved robustness of getColumnWidth methods
- Rebuild for not to give warnings due deprecated listener use with Vaadin 8.12.0
- Vaadin 8.12 or newer required
GridScrollExtension Add-on version 2.5.1
### Version 2.5.1
- Fix: Column widths should be reported also when ColumnResizeCompensationMode is NONE.