Skip to content

A utility class to set and read pixel based scroll positions of a Vaadin Grid

License

Notifications You must be signed in to change notification settings

stefanuebe/vaadin-grid-scroller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grid Scroller

A utility addon that provides a simply api to read and set the scroll position. The utility can be used with a wrapped grid or via static methods.

Usage

Set scroll positions

Grid<?> grid = new Grid<>();
// ... init grid

// specify the scroll values, e.g. from a previous view state
double topScroll = 100.0;
double leftScroll = 37.0;

// Set the scroll positions

GridScroller gridScroller = new GridScroller(grid);
gridScroller.scrollTop(topScroll);
gridScroller.scrollLeft(leftScroll);

// Alternatively you can call

gridScroller.scroll(leftScroll, topScroll);

// If you do not want to wrap the grid, use the static API

GridScroller.scrollTop(grid, topScroll);

// ...

Read the current scroll positions

Grid<?> grid = new Grid<>();
// ... init grid

GridScroller gridScroller = new GridScroller(grid);

// readPosition reads the position from the client side and passes it to a callback

gridScroller.readScrollPositions(scrollPosition -> 
    result.setText(scrollPosition.getLeft() + "," + scrollPosition.getTop()))
    
// If you do not want to wrap the grid, use the static API

GridScroller.readScrollPositions(grid, scrollPosition -> 
    result.setText(scrollPosition.getLeft() + "," + scrollPosition.getTop()))

About

A utility class to set and read pixel based scroll positions of a Vaadin Grid

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages