tags:

views:

74

answers:

1

What would be the best way to select all items in a datagrid.

I was thinking of doing a for loop and then select each item, but is there a better way for achieving this?

+1  A: 

What type of dataProvider are you using?

If you have an array, you can do this:

dataGrid.selectedItems = dataGrid.dataProvider;

If you have an ArrayCollection you can do this:

dataGrid.selectedItems = dataGrid.dataProvider.source;

For XML, you'll probably have to loop.

More info on the selectedItems property:

http://livedocs.adobe.com/flex/3/langref/mx/controls/listClasses/ListBase.html#selectedItems

www.Flextras.com