5 Replies Latest reply on May 11, 2009 7:05 PM by Michael Borbor

    Update DataGrid using RemoteObject

    fauziasyed

      I am using a RemoteObject method call to populate an ArrayCollection used as a dataProvider in my DataGrid. I use the render() method on the datagrid to make sure the datagrid displays the updated data the RemoteObject method is returning everytime it is displayed. My problem is the datagrid displays the updated information but gets into an infinite call.

       

      What might be the appropriate way to get the updated data from the backend?

       

      -Thanks,

      Fauzia

        • 1. Re: Update DataGrid using RemoteObject
          Michael Borbor Level 4

          If you make your AC bindable you just need to update the results in 

          the result handler and the DG automatically will show the updated data.

           

          Sincerely,

           

          Michael

           

          El 11/05/2009, a las 10:15, fauziasyed <forums@adobe.com> escribió:

           

          >

          I am using a RemoteObject method call to populate an ArrayCollection 

          used as a dataProvider in my DataGrid. I use the render() method on 

          the datagrid to make sure the datagrid displays the updated data the 

          RemoteObject method is returning everytime it is displayed. My 

          problem is the datagrid displays the updated information but gets 

          into an infinite call.

          >

          What might be the appropriate way to get the updated data from the 

          backend?

          >

          -Thanks,

          Fauzia

          >

          • 2. Re: Update DataGrid using RemoteObject
            fauziasyed Level 1

            Hi Michael,

             

            Thanks for your reply. The AC I use is bindable, but it doesn't get update with an initialize() method, thats why I had to use render(). This is an outline of my code...

             

             

              <mx:RemoteObject id="historyService" result="onResultGetList(event)" showBusyCursor="true" fault="onFault(event)" destination="historyService">
                 <mx:method name="getLrcFindDetailCltn" result="onResultGetList(event)" makeObjectsBindable="true" fault="onFault(event)"/>
               </mx:RemoteObject>

             

             

                   [Bindable]
                    private var ldsDetails:ArrayCollection;

             

                      public function getList():void
                    {
                        historyService.getLrcFindDetailCltn();
                    }

                      

                      public function onResultGetList(event:ResultEvent):void
                    {
                         ldsDetails = event.result as ArrayCollection;
                      }

             

                     

            <mx:DataGrid id="usersDataGrid" dataProvider="{ldsDetails}" render="getList();">
            <mx:columns>......

             

            Thanks,

            Fauzia

             

            • 3. Re: Update DataGrid using RemoteObject
              Michael Borbor Level 4

              You have to remember that flash player works asynchronously so 

              probably when your application loads still the data hasn't come back 

              from the server.

               

              Sincerely,

               

              Michael

               

              El 11/05/2009, a las 11:06, fauziasyed <forums@adobe.com> escribió:

               

              >

              Hi Michael,

              >

              Thanks for your reply. The AC I use is bindable, but it doesn't get 

              update with an initialize() method, thats why I had to use render(). 

              This is an outline of my code...

              >

              >

                <mx:RemoteObject id="historyService" 

              result="onResultGetList(event)" showBusyCursor="true" 

              fault="onFault(event)" destination="historyService">

                   <mx:method name="getLrcFindDetailCltn" 

              result="onResultGetList(event)" makeObjectsBindable="true" 

              fault="onFault(event)"/>

                 </mx:RemoteObject>

              >

              >

                    

                      private var ldsDetails:ArrayCollection;

              >

                        public function getList():void

                      {

                          historyService.getLrcFindDetailCltn();

                      }

              >

                        public function onResultGetList(event:ResultEvent):void

                      {

                           ldsDetails = event.result as ArrayCollection;

                        }

              >

              >

              <mx:DataGrid id="usersDataGrid" dataProvider="

              render="getList();">

              <mx:columns>......

              >

              Thanks,

              Fauzia

              >

              >

              • 4. Re: Update DataGrid using RemoteObject
                fauziasyed Level 1

                With the render() method I do get updated data everytime the datagrid is rendered..i.e, when I navigate to the screen the datagrid is on......but the problem is -it gets into an infinite loop, it keeps calling my backend java method many times.

                 

                With the initialize() method I get data only the first time I navigate to the datagrid screen, so everytime the screen shows me the old data.

                 

                When I debug I see the proper Data in my java code.....it is just that I am not able to retrive that data properly into my flex DataGrid. I want the DataGrid to call the backend java method once everytime the user navigates to the screen to update the dataProvider.

                 

                Thanks,

                Fauzia

                • 5. Re: Update DataGrid using RemoteObject
                  Michael Borbor Level 4

                  I'm you'll code will be more efficient if you set a timer or use

                  BlazeDS to manage pulling and pushing of data at a determined interval.

                   

                  Sincerely,

                   

                  Michael