2 Replies Latest reply on Nov 25, 2010 10:52 PM by Abhinav Sharma

    How to access the component id from another mxml?

    frank_zhang

      I tried to set the data to a DataGrid in another mxml, but the complier said there's a problem, like this:

       

      the components/FileDataGrid.mxml:

      <?xml version="1.0" encoding="utf-8"?>
      <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" >
      
          <mx:DataGrid x="150" y="50" id="dgFile">       <mx:columns>
               <mx:DataGridColumn headerText="COL"/>
             </mx:columns>
          </mx:DataGrid>
       
      </s:Group>
      
      

       

      the main mxml:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                xmlns:s="library://ns.adobe.com/flex/spark" 
                xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
                xmlns:custom="components.*" layout="absolute">
           <fx:Declarations>
                <!-- Place non-visual elements (e.g., services, value objects) here -->
           </fx:Declarations>
           
           <fx:Script>
                <![CDATA[
                     
                     private function loadDG():void
                     {
                          var arrFile:Array= new Array("abc","123");
                          
                          dgFile.dataProvider = arrFile;
                          
                          trace( "The data has successfully loaded" );
                     }
      
                ]]>
           </fx:Script>
           
           <s:Button  x="300" y="50" label="Load"  click="loadDG()" />
      
           <custom:FileDataGrid/>
      
      </mx:Application>
      

       

      The compiling error is :

      Multiple markers at this line:
      -1120: Access of undefined property dgFile.
      -arrFile

       

      Anybody can tell me, how to achieve it?

       

      Thanks a lot!