4 Replies Latest reply on Jul 31, 2008 7:17 AM by joshua.java

    Refreshing data in DataGrid

    joshua.java
      Dear all,

      I've got a list of data displayed in a datagrid where the DataProvider is from Spring as the backend. Now everytime I add, update or delete data, it doesn't refresh the datagrid. How do I do this in Flex?
      I've tried doing
      - dataProvider.refresh();
      - dataGrid.dataProvider.dispatchEvent(new CollectionEvent(CollectionEvent.COLLECTION_CHANGE));

      But none of them works. Is there a special treatment is the data provider is from a database? Please give me some hints on this.

      Many thanks
        • 1. Re: Refreshing data in DataGrid
          atta707 Level 2
          are you actually going back to the server to get the latest data; by using HTTPService or some equivelant RPC call? This refresh call, BTW, would be exactly same as the first one you sent to get data.
          • 2. Re: Refreshing data in DataGrid
            joshua.java Level 1
            quote:

            Originally posted by: atta707
            are you actually going back to the server to get the latest data; by using HTTPService or some equivelant RPC call? This refresh call, BTW, would be exactly same as the first one you sent to get data.


            I sent the data with RPC. So you mean after updating the data to the database, I need to return the list back again if I want the datagrid to be refreshed? Is that what you meant?

            Best regards,

            • 3. Re: Refreshing data in DataGrid
              atta707 Level 2
              if you have data already available on the client side -- that's what I'm assuming by your 'I sent data with RPC.' assertion -- then you definitely don't need to re-read it from database. In this case you should just add the new objects to existing ArrayCollection serving as the dataProvider for the grid.

              On the other hand, if database has been updated by some other process, you need to send a new HTTP request to fetch the new(er) data and display it.
              • 4. Re: Refreshing data in DataGrid
                joshua.java Level 1
                quote:

                Originally posted by: atta707
                if you have data already available on the client side -- that's what I'm assuming by your 'I sent data with RPC.' assertion -- then you definitely don't need to re-read it from database. In this case you should just add the new objects to existing ArrayCollection serving as the dataProvider for the grid.

                On the other hand, if database has been updated by some other process, you need to send a new HTTP request to fetch the new(er) data and display it.


                So you're saying that the current user input as another process also? How would Flex know that there's an update on the database? Is there any settings for this on BlazeDS?

                Many thanks