-
24 Feb 2013 6:11 PM #1
Unanswered: Force the selected row in the grid to scroll to the center
Unanswered: Force the selected row in the grid to scroll to the center
I want to make the row in the center of gird. I try code like this:
orCode:myGridView.ensureVisible(rowIndex, 0, true);
It just makes the row visible, sometimes the row is on the bottom of the grid.Code:myGridView.focusRow(rowIndex);
Is there any method to make the row in the center of the gird.
I know that ,we should call scroller.setScrollTop() function, but I don't know the value to set.
-
26 Feb 2013 9:08 AM #2
This should be some simple math - take the offset of the row you want (using getOffsetTop), and add half of the height of the scroller (getOffsetHeight), minus half of the height of the *row* (again, getOffsetHeight). This will center the row within the grid's scroller.
I've not tested this, but that would be my first move. Note that this is nearly what GridView.ensureVisible is doing, plus other math to account for the column and whether or not to scroll horizontally.


Reply With Quote