2 Replies Latest reply on Jul 20, 2010 11:36 PM by NewFlo

    ArrayCollection dataprovider

    docwisdom

      I am having a little problem populating a datagrid with an array collection. Thought maybe someone could help.

       

      I have this remoteobject code and accompanying AS code.

       

      -------------------------------------

      <s:RemoteObject id="serviceEditTicket" destination="ColdFusion" source="prism.cfc.serviceEditTicket" showBusyCursor="true">

      <s:method name="getOpenTicketsByTicketID" result="getOpenTicketsByTicketID_result(event);">

      <s:arguments>

      <tkid>

       

      </tkid>

      </s:arguments>

      </s:method>

      </s:RemoteObject>

      -------------------------------------

      [Bindable]

      private var getEditTicket:ArrayCollection;

      private function getOpenTicketsByTicketID_result(event:ResultEvent):void

      {

      getEditTicket = event.result.qGetOpenTicketsByTicketID as ArrayCollection;

       

      }

      -------------------------------------

       

      I then use getEditTicket as my dataprovider in the datagrid. Nothing seems to populate. When I debug, the ArrayCollection never gets populated in the variables panel.

      On the other hand, If I use serviceEditTicket.getOpenTicketsByTicketID.lastResult the datagrid populates just fine.

       

       

      What do you think I am doing wrong here?

        • 1. Re: ArrayCollection dataprovider
          Subeesh Arakkan Level 4

          Hi,

           

          Check if you are getting an Array as result instead of ArrayCollection. If you are getting an Array, you need to create a new ArrayCollection from the Array. Something like this

           

          getEditTicket = new ArrayCollection(event.result.qGetOpenTicketsByTicketID as Array);

          • 2. Re: ArrayCollection dataprovider
            NewFlo

            If you are sure your datafield-properties (at the datagrid columns) are set correctly, use the debug-Mode (if you are using Flex/Flashbuilder) to check the result-object. It happend to me that the arraycollection i wanted was one level down in the result-object like event.result.result. Also add eventlisteners for all errors and/or error-events so you don't miss an error during runtime. You can also use a sniffer like (http://www.charlesproxy.com/) to check your remote-call. At least this are things i often forget, so maybe it helps finding the problem.

             

            all the best