1) You can check the result object to find out if it is an Array. If it is an object, create a new array and add it to the array
private function selectfilesResult(eventObj:Event):void
if( eventObj.target.getResult().data is Array)
selectfiles = eventObj.target.getResult().data;
selectfiles = [ eventObj.target.getResult().data ] ;
2) Difference - The
DataGridcontrol is like a List except that it can show more than one column of data making it suited for showing objects with multiple properties.
you need to set labelField similar to dataField in DatagridColumns
Also check these links for more info
Message was edited by: Subeesh
Thank you for your answer.
But there is still something I don't get. I know that a Datagrid can show multiple fields and a List not.
What I don't understand is WHY you can use a result-object as is in the dataProvider of a Datagrid and NOT in a List.
What should I have to do to make this work?
You should be able to use the result as is for both List and Datagrid. Fundamentally, both classes process the dataProvider in the same way because the logic for this is defined in their common base class: ListBase. Take a look at the source for ListBase (ctrl+shift+t from an editor window in FB), and search for 'set dataProvider'.
There is one important difference: If you don't specify columns for your datagrid then it will inspect the first item of its dataProvider and generate a column per property. However, since the List does not have columns, you must specify a labelField or labelFunction so it has something to display.
Thank you for your explanation and the helpfull "labelField" -tip. It works now.
As a new comer to Flex (coming from web/PHP developping) it is not always easy to find those type of information. For example: in the language reference of List you don't find anything about "labelField". You find it in ListBase who is the base-Object. That is very confusing for a beginner... where to find the information.
1 person found this helpful
As a beginner you should probably use the Flex help as your first point of reference and the language reference as you become more familiar with the controls. For example, the Flex help does cover most of the core aspects of using the List control (although bizarrely it doesn't cover labelField specifically and only mentions it in passing):
When viewing the language reference, make sure you click the "show inherited..." links so that you see all properties / methods of the class.
Thank you Paul for all your good advices!