View Full Version : Manipulating GridView After Switching to it in CardLayout

21 Jun 2010, 9:45 AM
I have a panel with CardLayout that pages through various grids.

I want to adjust the handler that manages moving from card to card so that it scrolls the grid to a particular place when the user moves to a new card.

Unfortunately, the very first time the card loads, when the handler activates, I don't believe the grid is loaded to the extent that I can scroll it. I try to do that in the following code, and it doesn't work.

var navHandler = function(direction){
var layout = CardPanel.getLayout();
var active = layout.activeItem;
var idx = CardPanel.items.findIndexBy(function(o) {
return o == active;

var next = idx + direction;
var upperLimit = gridArray.length-1;

if(next <= 0) { next = 0; }
if(next > upperLimit) { next = upperLimit; }


// Code for adjusting the grid.

gridArray[next].getView().scroller.scrollTo('top', offset);

};I can't find an event on the grid object that triggers immediately after it appears in the Card panel. I felt like "afterlayout" might be a likely candidate, but it didn't trigger at the proper time.

How do I manipulate the GridView immediately after I load a new grid in my card layout?

Note: The grids are massive, 300 rows each, so I set deferredRender to true to make them function at all. I'm afraid this might be causing my problem, but I'm not sure how to resolve the issue so that I keep the benefits of deferredRender, but can also adjust the grid position when I switch screens.