It wasn't readilly apparent to me how to loop through some datagrid rows in Flex. Finally, I came across Abdul Qabiz's DataGridDataExporter class, which basically does just that.
The key is to set up a cursor that will loop through the Data Provider for the datagrid.
Something like this:
ACTIONSCRIPT:
-
var dp:Object=MyDG.dataProvider;
-
var cursor:IViewCursor=dp.createCursor();
-
while( !cursor.afterLast )
-
{
-
// Access each column field like: cursor.current.MyFieldName
-
trace(cursor.current.MyFieldName);
-
// Obviously don't forget to move to next row:
-
cursor.moveNext();
-
}
That's all there is to it.
Note to self (the Flex newbie): Test your HTML wrapper for your SWF files to make sure that the user experience is a good one when you're setting up your Flex apps on your site! I took the HTML wrapper generated by Flex Builder and modified it to fit into my page. While doing so, I forgot to include the playerProductInstall.swf file with my app, so when a browser with an older Flash Player viewed the page, the JavaScript I had in place to call playerProductInstall.swf would hang since it couldn't find it. The detection for when no Flash Player is present at all (or only a really old version) was also a bit ungraceful.
But I was clueless to these poor experiences since I hadn't tested these scenarios. Fortunately, my app was just released, and only to a beta crowd.
To test the absence of Flash Player, you can download a Flash Player Uninstaller and uninstall Flash Player. I'm not sure what the best way is to install and test an old version of the Flash Player; I just had a virtual machine that had an old version on it, so I used that because it was convenient. If you google for "download flash player 8", there are some non-Adobe links that appear to be valid links, but I did not try these.
Adobe has a Flash Player Detection and Installation support page that is helpful as well.