Hey all,
I need to programmatically scroll an AdvancedDataGrid component, without
changing the currently selected row, to an arbitrary item in a
HierarchicalData provider. I have another component that displays the
samedataset, and I want to synchronize the display states of
both,including select, mouseOver and mouseOut. The grid needs to scroll
as themouse is hovered over a new item in the other component. I've
posted an image here
<http://client.designcommission.com/temp/flex_component.jpg> to
illustrate.
This seems like it should be a fairly straightforward feature to
implement, but I've already wasted at least 10 hours struggling with it.
The issue, of course, is that scrollToIndex won't work since the list
item is most likely non-visible and doesn't have an item renderer
associated with it to pull an index from.
This is the event listener for the click event on the second graph,
which changes & scrolls to the new selection, and expands the newly
selected node. No problems there:
private function nodeClickHandler(e:NodeEvent):void
{
grid.selectedItem = e.target.nodeSource;
grid.expandItem(grid.selectedItem, true, true);
grid.scrollToIndex(grid.selectedIndex);
}
I also tried holding the current selection in a temporary variable,
changing the selection, then switching back to the original selection.
Doesn't work. I tried doing the same but delaying the reset for a frame
to give the list a chance to update, but that caused all kinds of odd
behavior with the indices.
var temp:Object = grid.selectedItem;
grid.selectedItem = e.target.nodeSource;
var itemIndex:uint = grid.selectedIndex;
grid.invalidateList();
grid.invalidateDisplayList();
grid.selectedItem = temp;
grid.scrollToIndex(itemIndex);
The only other method I could think of was to use a frameloop and
iterate through the list until the item came into view and returned a
renderer, but it started returning renderers even when the item was off
screen, and attempting to scroll to the renderer's index did nothing.
I'm at a complete loss here! Can anyone point me in the right
direction!?
Parker