6 Replies Latest reply on Sep 8, 2010 9:09 AM by betheflexcoder

    Can't get data to bind to DropDownList

    RandomReado Level 1

      I'm fetching some data from a PHP application using Zend AMF. However I can't get the data to bind to a simple DropDownList control. The PHP method is:

       

      class Test
      {
          public function myMethod()
          {
              $res = array();
              $res[] = array('NAME' => 'ThisIsATest', 'ID' => 1);
              return $res;
          }
      }
      


      Network Monitor reports the method is returning results. It's returning the following as an array:

       

      Array
      (
          [0] => Array
              (
                  [NAME] => Property
                  [ID] => 1
              )
      )
      

       

      Below is the code:

       

      <?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"
                             width="500" height="286"
                             creationComplete="initApp()">
          <fx:Script>
              <![CDATA[
                  import mx.collections.ArrayCollection;
                  import mx.rpc.events.FaultEvent;
                  import mx.rpc.events.ResultEvent;
         
                  private function myMethodResult(e:ResultEvent):void
                  {
                      searchType.dataProvider = e.result as ArrayCollection;
                  }
         
                  protected function initApp():void
                  {
                      service.myMethod();
                  }
         
                  protected function faultHandler(event:FaultEvent):void
                  {
                      trace(event.fault.faultString);
                  }
              ]]>
          </fx:Script>
          <fx:Declarations>
              <s:RemoteObject id="service"
                              destination="zend"
                              source="Test"
                              showBusyCursor="true"
                              fault="faultHandler(event)">
                  <s:method name="myMethod" result="myMethodResult(event)"/>
              </s:RemoteObject>
          </fx:Declarations>
          <s:DropDownList id="searchType" labelField="NAME"/>
      </s:WindowedApplication>
      

       

      Any help would be greatly appreciated. Thanks in advance.