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

  • ListGrid add operation that affects more than one record

    We have a use case where adding or updating one record in a ListGrid causes the middle tier (and back end) to update more than one record.

    We have attempted to return the changed record together with the primary record in the response from the middle tier. We expected the DataSource or ListGrid to resolve the records by primary key, but instead the secondary record is added to the ListGrid (and presumably DataSource).

    If you refresh the ListGrid, of course the proper data shows from the middle tier.

    Detailed break down:
    ID is flagged as a primary key in the data source.

    One record exists in the list grid with ID = 1 and PRIMARY_FLAG = 'Y'.

    A new record is added with ID = 2 and PRIMARY_FLAG = 'Y'. At this point the middle tier adds the new record and sets the old record to PRIMARY_FLAG = 'N', and sends both records back to the client.

    The client properly indicates that the newly added record has come back, but instead of updating the existing record to PRIMARY_FLAG = 'N' it instead adds a new record with PRIMARY_FLAG = 'N', leaving the original record in tact.

    My question is, is this supported and we're just doing something wrong? If not, what is the recommended approach to achieve the desired results?


  • #2
    Any suggestions?



    • #3
      Hi Rob,

      Sorry for the delay.

      There isn't really a built-in behavior for this. Probably the best thing to do is to add some additional data to your response, separately from, that encodes the updates that need to happen to other records. Pick this data out of the raw response data in DataSource.transformResponse() and place it somewhere on the DSResponse object (eg dsResponse.myExtraUpdates), and use notifications on the grid, such as editComplete(), to apply the updates directly to ListGrid records and call refreshCell / refreshRow or just markForRedraw() to update the display.


      • #4
        We'll give that a shot, thanks.