I'm building a component that contains a DataGrid with fixed width columns 
whose (the 
DataGrid's) actual width I set in its parent's updateDisplayList method. If the 
contents of 
the grid are larger than this explicit size I want it to scroll in either 
direction. This works 
fine. 

However, I also need to synchronize scrolling with another sibling component 
whose width 
is set to the same width as the DataGrid (i.e. my column headers component 
needs to 
scroll horizontally with the grid). The problem is when the grid has fixed 
width columns 
there is a mysterious "pseudo-column" at the far right (presumably to make 
rendering 
more efficient). This screws up all of my scroll calculations. Here's the 
listener for the 
DataGrid's ScrollEvent: 

private function onGridScroll(event:ScrollEvent):void {
        var delta:Number = event.delta;
        var dir:String = event.direction;

        if(ScrollEventDirection.HORIZONTAL == dir)  {
                columnHeaders.horizontalScrollPosition = 
grid.horizontalScrollPosition * 
cellWidth;
        }
}

where cellWidth is the static column width.

For all but the last delta above, scrolling is synchronized. However, for the 
last delta (i.e. 
when the grid is scrolled all the way to the right) the grid and the headers 
are out of synch 
because the columnHeaders component is actually skinnier than the grid's 
contents by an 
amount the size of this "pseudo-column".  

Based on <http://groups.google.com/group/flex_india/browse_thread/thread/
18b2badb90a6524f"> it looks like some magic is happening in the private 
DataGrid. calculateColumnSizes.

Does anyone have any idea how I might synchronize horizontal scrolling in this 
situation?

Any help would be much appreciated.

Reply via email to