6 Replies Latest reply on Apr 30, 2008 3:40 PM by ntsiii

    Another Datagrid question

    Developer504 Level 1
      Hi folks!

      I am trying to take some XML data I have retrieved from HTTPService request and display it on a datagrid.

      I understand the basic idea is to bind the result to an array, and then parse out that array somehow so that the datagrid can read it. If that is wrong please correct me.

      So far I have

      import mx.collections.ArrayCollection;
      private var myData:ArrayCollection;

      This part isn't working

      <mx:HTTPService id="loginService"
      url=" http://localhost/magic94scripts/mgrqcgi94.exe"
      result="myData = resultObj.catalog as ArrayCollection">

      Can somebody tell me what I've missed here?

      Mr. Dummy
        • 1. Re: Another Datagrid question
          ntsiii Level 3
          1) The default resultFormat is "Object". This causes Flex to convert your xml into a nested dynamic obbject structure. This is rarely desirable. On your HTTPService tag, set resultFormat="e4x". Thsi will leave the xml alone.
          2) You can't put XML directly into an arrayCollection. Use the XML as it is, or put it into an XMLListCollection.
          3)Use a result handler function so you can inspect and manipulate your data. Use a fault handler also.
          4) You must invoke send() on the HTTPService.

          I will post some example code when I get to my other system.

          • 2. Re: Another Datagrid question
            Developer504 Level 1
            Thanks a lot tracy . I got it working with the help of Mabs Corp from this forum. Currently I'm using the XML directly as it is, which seems to be working fine. I don't fully understand precisely how the E4X format changes the XML data, but I'm going to read up on that.

            I have another question though, if I want to invoke the loginService.send() through a timed event, like say, every two minutes? Currently I'm launching it from a button.

            Mr. Dummy
            • 3. Re: Another Datagrid question
              ntsiii Level 3
              Certainly you can invoke send via a timer. I have a simple example of that on www.cflex.net.

              To clarify resultFormat="e4x" does NOT change the data. The default resultFormat="object", DOES convert the xml into a tree of dynamic Objects. You do not want this.

              • 4. Re: Another Datagrid question
                Developer504 Level 1
                Thanks Tracy,

                I'll take a look at cflex.net and see if I can find that example.

                When I insert resultFormat="e4x" into my test app, it stops working. Currently I'm populating the Datagrid like this:

                <mx:DataGrid id="myDG2"

                dataProvider="{loginService2.lastResult.catalog.record}" x="643" y="128" width="613" height="658">
                <mx:DataGridColumn headerText="Name" dataField="name" />
                <mx:DataGridColumn headerText="Status" dataField="status" />
                <mx:DataGridColumn headerText="Type" dataField="type" />
                <mx:DataGridColumn headerText="Category" dataField="category" />

                With loginService2 being my HTTPService call.
                • 5. Re: Another Datagrid question
                  Developer504 Level 1
                  Tracycan you give me some idea of where to find that example Cflex seems like a pretty large site