I tried your suggestion (using selectedItems, since selectedIndices 
is all but meaningless in a tree-view AdvancedDataGrid). Now the 
problem is even stranger. I add a bunch of items from the 
dataProvider into a new array. Then I assign the array to 
selectedItems. By the next line of code, selectedItems is down to 
just the clicked item, and the first item that was programmatically 
selected.


// On click of a top-level item:
private function onGridClick(event:ListEvent):void
{
...
var items:Array = new Array();

// Preserve currently clicked items
for (var idx:int=0; idx<grid.selectedItems.length; idx++)
items.push(grid.selectedItems[x]);

// Add all of the clicked item's children to the list
var children:ArrayCollection = gridData[clickedItemIdx].children;
for (idx=0; idx<children.length; idx++)
{
items.push(children[x]);
}

// Overwrite selectedItems
grid.selectedItems = items;

// BUG: At this point, both "grid.selectedItems" and "items" contain 
// only two elements: the clicked item, and the first of the item's 
// children.

}



--- In [email protected], "fourctv" <[EMAIL PROTECTED]> wrote:
>
> adg.selectedItems and adg.selectedIndices are arrays.
> 
> selectedItems is an array of objects from adg's dataProvider taht 
are currently selected, 
> and it is a read/write property.
> selectedINdices otoh is an array of ints with indices for those 
same objects in 
> selectedItems.
> 
> so, to make it simple, if you want to select rows 2,4,6 you'd do 
something like:
> var mySelection:Array = [2,4,6];
> adg.selectedINdices = mySelection;
> 
> hth
> julio
> 
> --- In [email protected], "whatabrain" <junk1@> wrote:
> >
> > Sorry. I missed a detail... I tried to do:
> >   grid.selectedItems.push(o).
> > It did not cause the item to be selected.
> > 
> > 
> > --- In [email protected], "fourctv" <fourctv@> wrote:
> > >
> > > You have 2 options, set either adg.selectedItems or 
> > adg.selectedIndices.
> > > 
> > > --- In [email protected], "whatabrain" <junk1@> wrote:
> > > >
> > > > Another old question, I'm sure, but I can't find an answer 
> > anywhere on 
> > > > the web.
> > > > 
> > > > How do I cause a row to be selected in an AdvancedDataGrid? 
> > Basically, 
> > > > when a top-level element is clicked, I want all of its child 
> > elements 
> > > > to be selected.
> > > >
> > >
> >
>


Reply via email to