View Full Version : GridView, given a rowIndex, how to scroll it to the center of its viewport?

23 Sep 2007, 7:06 PM

I have a GridView sized to show 10 records at a time but when I call GridView.ensureVisible(89, 0, false) the 90th record appears at the bottom of the GridView's view port. I would like to know how to get row 89 to be centered vertically in the view port. Of course whenever possible.

How would I do this?

Help - thanks in advance!

23 Sep 2007, 11:10 PM
You can do this by doing your own arithmetic on the View's Element's scrollTop property.

Take a look at it using Firebug as you scroll the View.

You will have to know the offsetTop of the View item that you need, and the depth of the View's visible area (clientHeight), and then do your arithmetic, and set the View's Element's scrollTop.