1 Reply Latest reply on Oct 5, 2011 4:07 PM by Flex harUI

    file browsing and showing selected files in a datagrid? i'm missing something small... i hope

    madhooper Level 1

      I am currently allowing the user to browse and select multiple files. I'd like to display the selected files in a datagrid. Here's my code. What am I missing?

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"

                                                           xmlns:s="library://ns.adobe.com/flex/spark"

                                                           xmlns:mx="library://ns.adobe.com/flex/mx">

        <fx:Declarations>

        <!-- Place non-visual elements (e.g., services, value objects) here -->

        </fx:Declarations>

       

        <fx:Script>

                          <![CDATA[

                                    import mx.collections.ArrayCollection;

       

                                    public var Files:File;

       

                                    [Bindable]

                                    public var arrUploadFiles:Array;

       

                                    private function init():void

                                    {

                                              arrUploadFiles = new Array()

                                              Files = new File(); 

                                              Files.addEventListener(FileListEvent.SELECT_MULTIPLE,onSelect_multiple_files); 

                                              Files.browseForOpenMultiple("Select Files to Send!!"); 

                                    }

       

                                    public function onSelect_multiple_files(f_evt:FileListEvent):void

                                    { 

                                              for each(var tempF:File  in f_evt.files){ 

                                                        tempF.load(); 

                                                        arrUploadFiles.push(tempF);

                                                        trace (tempF.nativePath);

                                    }

       

                          ]]>

        </fx:Script>

       

                <s:Button x="259" y="454" label="Browse for Files" click="init()"/>

                <s:DataGrid x="159" y="211" requestedRowCount="4">

        <s:columns>

        <s:ArrayList>

                                              <s:GridColumn dataField="dataField1" headerText="Column 1"></s:GridColumn>

                                              <s:GridColumn dataField="dataField2" headerText="Column 2"></s:GridColumn>

                                              <s:GridColumn dataField="dataField3" headerText="Column 3"></s:GridColumn>

        </s:ArrayList>

        </s:columns>

        <s:typicalItem>

                                    <fx:Object dataField1="Sample Data" dataField2="Sample Data" dataField3="Sample Data"></fx:Object>

        </s:typicalItem>

        <s:ArrayList>

                                    <fx:Object dataField1="data1" dataField2="data1" dataField3="data1"></fx:Object>

                                    <fx:Object dataField1="data2" dataField2="data2" dataField3="data2"></fx:Object>

                                    <fx:Object dataField1="data3" dataField2="data3" dataField3="data3"></fx:Object>

                                    <fx:Object dataField1="data4" dataField2="data4" dataField3="data4"></fx:Object>

        </s:ArrayList>

        </s:DataGrid>

       

      </s:WindowedApplication>