Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ListGrid data updates

    Hi,

    I have a ListGrid and a DynamicForm, bound to the same DataSource.
    I have them configured so that when a record is selected in the ListGrid,
    it's edited in the form.

    If I am not mistaken, when the form is saved, the following things happen with the ListGrid (among other things):

    - The contents are upgraded with the updated data.
    - The configured Data
    ArrivedHandlers are _not_ called.
    - The selection is lost.

    Questions:

    1. Is this really how it works? (I am asking because there are a lot of other other things happening in the background, so I might have mixed up something)

    2. Can I configure it so that the dataArriveHandlers are also called on updates?

    3. If not, then how am I supposed to react to the changes on the ListGrid level? (The data is automatically upgraded, which is fine, but might need to do other things, too.) Is there a hook for this? (Now I am using the return callback of the form save, but this is not nice, since the grid and the form should not even have to know about each other existence; the DataSource itself should be a sufficient link.)

    4. Can I configure the ListGrid to retain the selection, and not to drop in on data changes? (Right now, I am restoring in manually.)

    Thank you for your help!

    #2
    1. Yes

    2 & 3. No, call whatever logic you need to from the saveData() callback. If the grid and form are intended to be tightly integrated, make them a component or subclass one or the other with behavior where it knows about a grid which you provide.

    4. No, restore it manually.

    Comment


      #3
      Originally posted by Isomorphic
      If the grid and form are intended to be tightly integrated, make them [...]
      I do not necessarily want them to be tightly integrated; I just need them to behave individually decently. I mean, right now, for my point of view, they are interfering with each other, sometimes in unwanted ways.

      For example, I may have many different surfaces in my application, among which many could contain ListGrids, showing some projection of basically the same data set.

      When a form (or ListGrid) changes the data, all the other ListGrids (which are located at possibly independent parts of the application, some not even visible at the moment) are upgraded, and lose the selection. If I want to avoid this, I have to keep track of all the ListGrids to notify... this is definitely not what I want.

      In my opinion, the root cause of the problem is that even though the ListGrids are notified of the upgrades (and upgraded), there is no hook to notify the objects using the ListGrids.

      The situation could be easily improved by adding an upgradeArrived handler to the ListGrids (akin to the dataArrived handler), which would be called the the ListGrid is updated because of some data change.

      What do you think of this?

      Comment


        #4
        Already there (DataChanged on ResultSet).

        Comment


          #5
          Getting close, but I am not sure this is exactly what I imagined. The docs for RecordList.addDataChangedHandler says this:

          Notification fired when data changes in some way. Note that this will only fire when items are added, removed or rearranged. If a list contains objects, this method will not fire if changes are made to objects within the list without changing their position within the list
          This gives me the impression that this notification is not called for upgrades. Or is it?

          Comment


            #6
            It is in the case of any kind of update due to cache sync.

            Comment


              #7
              Originally posted by Isomorphic
              Already there (DataChanged on ResultSet).
              Adding such handler seems to disrupt the working of the ListGrid.
              (For example, making a big jump the the middle of record no longer works, nor do updates.)

              I am adding the handler like this:
              Code:
              grid.getResultSet().addDataChangedHandler(...);
              Is this how it's supposed to work? If yes, then please see attached test case.

              You can fetch the data from here: http://www.nolmecolindor.com/isomorp...htest_data.sql... but any dataset would be OK, just make it long enough (>500 records).
              Attached Files

              Comment


                #8
                I have tried this both with S'GWT 2.1 and latest nightly (may 02). Results were the same.

                (FF 3.5.9, Linux)

                Comment


                  #9
                  Thanks for the test case. There was a weird interaction with how SmartGWT attaches to events and the observe() mechanism in SmartClient, now fixed.

                  Comment


                    #10
                    When a form (or ListGrid) changes the data, all the other ListGrids (which are located at possibly independent parts of the application, some not even visible at the moment) are upgraded, and lose the selection. If I want to avoid this, I have to keep track of all the ListGrids to notify... this is definitely not what I want.
                    Not that hard to do actually, if you follow the GWT MVP design pattern with SmartGWT. I.e. de-couple the various listgrids showing the dataset, and instead register them as event listeners with a central event bus. When data changes, the component changing the data (for instance a form) pushes an event to the EventBus. Interested ListGrids are listening for these events and if an event passes by that should force them to update their own display; they can intercept it and act accordingly.

                    Comment


                      #11
                      Hi all ...
                      We have our own Datasource implementation that subscribes for events to our server and calls update caches to notify any ListGrids that are attached to the Datasource. The problem is if some of those listgrids have an active filter, how do I know what to set the total rows to in the DSResponse since I could have multiple Filtered ListGrids all working off of this Datasource ?

                      I'm think I need to add my own custom DataArrivedHandler to the ListGrid to apply the filter and increment or decrement the total rows in the ListGrid if the filter matches ... would this be the correct approach ? We need the row count for paging and I really don't want to call invalidate cache.

                      Thanks for the help,
                      Mike.

                      Comment


                        #12
                        Anyone got any thoughts ? I'd have thought the new (in 2.2) update caches method would work with filtered listgrids as well as unfiltered without me having to implement a listener, but if it doesn't fair enough ...

                        Comment

                        Working...
                        X