Scroll grid row

can we scroll a grid to a specified row>
ie: i have 100 rows in a grid, i want to scroll the grid to row 58 and display it on first row of visible row


Use grdid1_ref.scrollTo(0, b) where b is the number of pixels down the grid to scroll to. b is a negative number. Determine how far to scroll by determining the number of pixels per row with grid1.scrollHeight. Then use grid1_ref.scrollTo to move to this row:

grid1.refresh 'load your grid and refresh
n = grid1.scrollHeight/100  'number of pixels per row when there are 100 rows in the grid
gotorow = 60 'the row in the grid to go to
b = (n * gotorow) * -1 'where gotorow is where you want to scroll to (the goto number is negative)
grid1_ref.scrollTo(0, b)

To see this in action go to This procedure uses the Common Grid in NSB set to scrolling. The initial values for a Date or Time position the three grids accordingly. The centering after the user manually scrolls is done using

 grid1_ref.on("scrollEnd", scrollEnd1) 'one for each of the grids

The function scrollEnd1 is called when the scrolling stops. The code then uses the above ref.scrollTo to center the stop point on the grid. The smooth scrolling is done by using a SetInterval to incrementally set the position until it is just right.


1 Like