Flex: datagrid select all items

apache-flexdatagrid

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?

Best Answer

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

Related Topic