5 Replies Latest reply on Aug 2, 2006 7:29 AM by Newsgroup_User

    Flex 2.0 simple DataGrid Sample topped working

    Level 7
      This sample (provided with the Beta3) does not seem to work anymore. Can
      anyone clue me in? It seems that type checking has gotten stricter. (the
      employees.xml file can be found in the /assets folder of the samples. I
      place it at the end of this note.


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Box xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%" height="100%"
      creationComplete="srv.send()">

      <mx:Script>

      import mx.collections.ArrayCollection;

      [Bindable]
      public var employees:ArrayCollection;

      </mx:Script>

      <mx:HTTPService id="srv" url="assets/employees.xml" useProxy="false"
      result="employees = new
      ArrayCollection(srv.lastResult.list.employee)"/>


      <mx:DataGrid id="dg" width="100%" height="100%"
      dataProvider="{employees}">
      <mx:columns>
      <mx:Array>
      <mx:DataGridColumn dataField="name" headerText="Name"/>
      <mx:DataGridColumn dataField="phone"
      headerText="Phone"/>
      <mx:DataGridColumn dataField="email"
      headerText="Email"/>
      </mx:Array>
      </mx:columns>
      </mx:DataGrid>

      </mx:Box>

      TypeError: Error #1034: Type Coercion failed: cannot convert
      mx.collections::ArrayCollection@1519761 to Array.
      at DataClip/__srv_result()
      at
      flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at
      mx.rpc.http.mxml::HTTPService/ http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()
      at
      mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::resultHandler()
      at mx.rpc::Responder/result()
      at mx.rpc::AsyncRequest/acknowledge()
      at ::DirectHTTPMessageResponder/completeHandler()
      at
      flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at flash.net::URLLoader/flash.net:URLLoader::onComplete()


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

      <list>

      <employee>
      <name>Christina Coenraets</name>
      <phone>555-219-2270</phone>
      <email>ccoenraets@fictitious.com</email>
      <active>true</active>
      </employee>
      <employee>
      <name>Louis Freligh</name>
      <phone>555-219-2100</phone>
      <email>lfreligh@fictitious.com</email>
      <active>true</active>
      </employee>
      <employee>
      <name>Ronnie Hodgman</name>
      <phone>555-219-2030</phone>
      <email>rhodgman@fictitious.com</email>
      <active>false</active>
      </employee>
      <employee>
      <name>Joanne Wall</name>
      <phone>555-219-2012</phone>
      <email>jwall@fictitious.com</email>
      <active>true</active>
      </employee>
      <employee>
      <name>Maurice Smith</name>
      <phone>555-219-2012</phone>
      <email>maurice@fictitious.com</email>
      <active>false</active>
      </employee>
      <employee>
      <name>Mary Jones</name>
      <phone>555-219-2000</phone>
      <email>mjones@fictitious.com</email>
      <active>true</active>
      </employee>

      </list>


        • 1. Re: Flex 2.0 simple DataGrid Sample topped working
          ntsiii Level 3
          I understand that the newest Flash Player 9 version has some problems with Beta3 code.

          Tracy
          • 2. Re: Flex 2.0 simple DataGrid Sample topped working
            Kishan M V Adobe Employee
            Set makeObjectsBindable="false" for the HTTPService request.

            <mx:HTTPService id="srv" url="employees.xml" useProxy="false" makeObjectsBindable="false"
            result="employees = new
            ArrayCollection(srv.lastResult.list.employee)"/>

            Thanks
            Kishan
            • 3. Re: Flex 2.0 simple DataGrid Sample topped working
              Level 7
              Thank you Kishan, That did it.

              But can you explain why this works. (and also pass a note to the owners of
              LiveDocs that the documentation about this parameter is a bit thin

              makeObjectsBindable:Boolean [read-write]
              When this value is true, anonymous objects returned are forced to bindable
              objects.

              Implementation
              public function get makeObjectsBindable():Boolean
              public function set makeObjectsBindable(value:Boolean):void



              "Mavenki" <webforumsuser@macromedia.com> wrote in message
              news:eaknva$sf0$1@forums.macromedia.com...
              > Set makeObjectsBindable="false" for the HTTPService request.
              >
              > <mx:HTTPService id="srv" url="employees.xml" useProxy="false"
              > makeObjectsBindable="false"
              > result="employees = new
              > ArrayCollection(srv.lastResult.list.employee)"/>
              >
              > Thanks
              > Kishan
              >


              • 4. Re: Flex 2.0 simple DataGrid Sample topped working
                peterent Level 2
                Results that come back which look like Arrays will be turned into ArrayCollections automatically. Since most people immediate turn an Array into an ArrayCollection, we went ahead and did it for you. Try getting rid of your new ArrayCollection in the result handler.
                • 5. Re: Flex 2.0 simple DataGrid Sample topped working
                  Level 7
                  If I understand this correctly. Then would it not make more sense to say in
                  the LiveDocs --

                  makeObjectsBindable - After the remote call (RPC, HTTP, SOAP, etc) returns
                  its value. Flex tries to automatically convert the result into an
                  ArrayCollection (if it looks like an array, even if it was XML) [Or
                  others???] format. This automatic conversion controlled by the
                  makeObjectBindable property. If false, Flex does not attempt the conversion
                  and the result will be in (xml?) format.


                  "peterent" <webforumsuser@macromedia.com> wrote in message
                  news:eali1i$1q9$1@forums.macromedia.com...
                  > Results that come back which look like Arrays will be turned into
                  > ArrayCollections automatically. Since most people immediate turn an Array
                  > into
                  > an ArrayCollection, we went ahead and did it for you. Try getting rid of
                  > your
                  > new ArrayCollection in the result handler.
                  >