In my Flex project, I have a service function getItems() that returns me a collection/array of Item objects.
The function runs an SQL statement like SELECT * FROM table. I therefore do not want to use a SELECT COUNT SQL statement.
I know that if I use a Flex spark:DataGrid, I can easily get the length of the datagrid to know the number of rows (which in my case, would be the number of objects returned by my getItems() function). However, I am using an mx:AdvancedDataGrid and it is not possible to get the length by the same means as with the spark:DataGrid.
Actually, I need to dynamically create a set of labels with text={ItemName}. Using a Vbox and a for loop, I am able to create a list of labels. At the moment, I have a random number for the delimiter in my for loop. I just need to get the number of objects returned by my getItems() function. I can then put that number in the for loop and the job is done.
At least, this is how I plan to do this task.
Is there a better way to do this?
PS: I have Googled extensively, but I could not find any working examples for what I want to do.
Suggestions are welcome and StackOverflow is fabulous!
[EDIT] I eventually used an mx:Repeater to do the task described above.
how about this:
private function getItemsResultHandler(event:ResultEvent):void
{
var items:ArrayCollection = new ArrayCollection();
items = event.result as ArrayCollection;
trace(items.length);
}