I believe the answer is to use callLater before acting on the AdvancedDataGrid. 
However, the kink is that my dataProvider isn't set until XML is loaded. 

Here is the setter for the dataProvider (source of my GroupingCollection):
public function set applications( arr:Array ):void{
                                _applications = arr;
                                appColl.source = applications;
                                callLater( expandRow );
                        }

..And then here is the expandRow() method:
private function expandRow():void{
                                // Expand the first row of the ADG
                                var obj:Object = gc.getRoot(); 
                                var temp:Object = 
ListCollectionView(obj).getItemAt(0); 
                                grid.expandItem(temp,true);
                        }

<mx:dataProvider>
            <mx:GroupingCollection id="gc" source="{appColl}">
                <mx:Grouping>
                    <mx:GroupingField name="label"/>
                </mx:Grouping>
            </mx:GroupingCollection>
        </mx:dataProvider> 

The error I get when I run this code is this:

Index '0' specified is out of bounds.

I'm just not sure why this might be happening. I mean, I'm using callLater..Any 
ideas? 
--- In flexcoders@yahoogroups.com, "fumeng5" <fume...@...> wrote:
>
> Hi,
> 
> I'm trying to expand the first row of my AdvancedDataGrid column when it is 
> loaded with my XML data. I've found plenty of examples online that show how 
> to do it from a click event, but nothing on init of the grid. I've tried the 
> initialize method, the setter of my dataProvider method but they all give me 
> a range out of bounds error. 
> 
> Here's my function:
> 
> private function expandRow():void{
>                               // Expand the first row of the ADG
>                               var obj:Object = gc.getRoot(); 
>                               var temp:Object = 
> ListCollectionView(obj).getItemAt(0); 
>                               grid.expandItem(temp,true);
>                               grid.validateNow();
>                       }
> 
> Anyone know the proper event to trigger this? 
> 
> Thank you,
> 
> Matt
>


Reply via email to