5 Replies Latest reply on Mar 17, 2008 2:16 PM by Tropics2

    Refresh datagrid with new content

      Hey guys,
      I'm new to flex and I'm stuck with a small problem...
      i have a XML file which is the output of a MySQL table. Now, i have a httpservice that loads this XML file then with the result event send the data to a datagrid. Now the problem is that the table is getting updated once an hour and the XML that it outputs also gets updated, to get the table updated i wanted to add a "refresh" button to reload the data from the new XML file and show it on the datagrid.. i tried calling the send() function of the httpservice after clicking on the refresh button and then use the arraycollection refresh() but no luck there..
      Is there any way to get the httpservice reload the XML file and then update the datagrid to show it?
      Thank you for taking the time to trying to help me
        • 1. Re: Refresh datagrid with new content
          Gregory Lafrance Level 6
          I wonder if it is possible to use data binding and/or model in this case? These FB 2.0.1 help topics (or through LiveDocs) might be of use:

          Defining bindings in ActionScript
          Defining binding watchers
          Binding a service result to other objects
          Using RPC services
          Defining a data model
          Specifying an external source for an <mx:Model> tag or <mx:XML> tag
          • 2. Re: Refresh datagrid with new content
            Tropics2 Level 1
            Hey Greg,
            Thanks for the quick answer ;)
            I'm not sure im clear on what you are suggesting so i hope you dont mind me asking: when you say defining bindings in actionscript you mean setting the httpservice url's and send() function within the click function of the refresh button?
            If now i would really appriciate if you can supply more details on your suggestions.
            Thanks :)
            • 3. Re: Refresh datagrid with new content
              ntsiii Level 3
              You are not showing any code so it is hard to say what is wrong, but this should work fine.

              Are you using method="POST", an resultFormat="e4x"?

              Also, do NOT BIND directly to lastResult, it is too hard to debug. Instead, use a result handler function. Put a trace statement in the result handler, using toXMLString() on the event.result. Make sure you know what you are getting.

              • 4. Re: Refresh datagrid with new content
                Tropics2 Level 1
                Hey Tracy,

                Why shuold i use method="POST", an resultFormat="e4x"?
                What i wrote was:
                <mx:HTTPService url=".../tableData.xml" id="taxiService" result="taxiHandler(event)"/>

                then the taxiHandler function:
                import mx.rpc.events.ResultEvent;
                import mx.collections.ArrayCollection;
                private var taxiArray:ArrayCollection = new ArrayCollection();
                private function taxiHandler(evt:ResultEvent):void

                then i added the refresh button by using <mx:button> and in its click function i tried to do taxiService.send() (to reload the httpservice) and then refresh the data array but like i said it didnt update the datagrid :(

                shuold i try setting the method to POST in the 2nd time i call the taxiservice httpservice?
                Thanks for your help :)
                • 5. Re: Refresh datagrid with new content
                  Tropics2 Level 1
                  any new ideas maybe? ;c