1 Reply Latest reply on Sep 14, 2006 12:40 PM by Bill Sahlas

    grid is not populating on creationComplete

    hkk
      hi, im a flex newbie, and cannot get the grid populated at creationcomplete.
      if ic click on the the button with the function myService.sayHelloQuery(), the grid shows the data from the coldfusion cfc
      whats wrong with my code?

      thanks
      herbert

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="myService.sayHelloQuery();">
      <mx:Script>
      <![CDATA[
      import mx.rpc.events.ResultEvent;
      import mx.controls.Alert;
      import mx.collections.ArrayCollection;


      [Bindable]
      public var qResult:ArrayCollection;


      }
      public function handleQueryResult(event:ResultEvent):void{
      qResult=event.result as ArrayCollection;
      }
      ]]>
      </mx:Script>

      <mx:RemoteObject
      id="myService"
      destination="ColdFusion"
      source="HelloWorld"
      showBusyCursor="true"/>

      <mx:method name="sayHelloQuery" result="handleQueryResult(event)" fault="Alert.show(event.fault.message)"/>

      </mx:RemoteObject>

      <mx:Button label="get Query Remote Object" click="myService.sayHelloQuery()"/>
      <mx:DataGrid dataProvider="{qResult}">
      <mx:columns>
      <mx:Array>
      <mx:DataGridColumn dataField="hello"/>
      <mx:DataGridColumn dataField="world"/>
      <mx:DataGridColumn dataField="exclamation"/>
      </mx:Array>
      </mx:columns>
      </mx:DataGrid>


      </mx:Application>
        • 1. Re: grid is not populating on creationComplete
          Bill Sahlas Level 1
          I've chaged your code slightly and added comments to help explain -

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="initApplication();">
          <mx:Script>
          <![CDATA[
          import mx.rpc.events.ResultEvent;
          import mx.controls.Alert;
          import mx.collections.ArrayCollection;


          private function initApplication():void
          {
          // myService is the RemoteObject tag reference id
          // once the application creation is complete call myService.sayHelloQuery() method
          this.myService.sayHelloQuery();
          }


          [Bindable]
          public var qResult:ArrayCollection;


          }
          public function handleQueryResult(event:ResultEvent):void{
          qResult=event.result as ArrayCollection;
          }
          ]]>
          </mx:Script>

          <mx:RemoteObject
          id="myService"
          destination="ColdFusion"
          source="HelloWorld"
          showBusyCursor="true"/>

          <mx:method name="sayHelloQuery" result="handleQueryResult(event)" fault="Alert.show(event.fault.message)"/>

          </mx:RemoteObject>

          <mx:Button label="get Query Remote Object" click="myService.sayHelloQuery()"/>
          <mx:DataGrid dataProvider="{qResult}">
          <mx:columns>
          <mx:Array>
          <mx:DataGridColumn dataField="hello"/>
          <mx:DataGridColumn dataField="world"/>
          <mx:DataGridColumn dataField="exclamation"/>
          </mx:Array>
          </mx:columns>
          </mx:DataGrid>


          </mx:Application>