Announcement

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

    related updates between data sources related by inheritance

    Hi,

    I am developing a custom data source that extends BasicDataSource, and supports several data sources that are related by inheritance. For purposes of this discussion, assume that I have two data sources: Base and Derived, where Derived inherits from Base. In my application I have several data bound components displayed at one time, for example a TreeGrid displaying Base records, and a ListGrid displaying Derived records.

    If I add/update/remove a Base record from the TreeGrid, what I would like is that the corresponding Derived record in the ListGrid is also added/updated/removed, and vice-versa. This happens automatically if the components are bound to the same data source, but does not seem to happen if they are different data sources related by inheritsFrom. I am able to accomplish this manually, either by using DSResponse.addRelatedUpdate() on the server (or DataSource.updateCaches()).

    My question is: should this happen automatically? If so, then I am doing something wrong and will need to try to determine why it is not working for me. If not, then is my manual approach described above the best way to accomplish the desired result?

    Thanks!

    ====
    Version: v8.3p_2012-12-31/Pro Deployment (built 2012-12-31)
    Browser: Firefox 17.0.5

    #2
    No, it is not intended to happen automatically (by design), and yes, your approach for manually updating the related DS is correct.

    Comment


      #3
      Thanks for the quick response.

      Comment


        #4
        I'd like to also confirm that related updates it also the correct way to handle deletions when hierarchical data is involved (using rootValue and foreignKey in the data source). Let's say that I have a record A, with child B, and B has child C. All three records are being displayed in a ListGrid, and A is deleted. This results in deletion of descendants B and C by the data source.. I'm assuming that the data source would be responsible for sending related updates (delete) for B and C so that they would be removed from the ListGrid in the client, correct?

        Comment


          #5
          Yes, addRelatedUpdates() is intended as a way to deal with hierarchical data.

          Note that just removing the parent is enough to remove all the children from a SmartGWT Tree. But if you are actually deleting the child records from permanent storage and they are shown elsewhere on the screen (eg in a ListGrid), then you would want to use addRelatedUpdates() to cause the records to be removed from these other widgets.

          Comment

          Working...
          X