Announcement

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

    Synchronize subordinate records between grids

    Hi, sorry in advance if this question is convoluted. I have a question about synchronizing data between two grids. I have two grids that share the same datasource. When I add data to one grid, I want it to show up in the second grid. This has been working fine for us for a long time. However, we need to make the following enhancement.


    Grid 1 is the grid that will receive an update via cache synchornization from Grid 2:
    Code:
    Grid 1 (DataSource: FundAsset)
    
    FundAsset ID	Name			SubordinateList (hidden attached List of DataSource: FundAsset)
    1		Aggregate FundAsset	Subordinate FundAsset ID 2, Subordinate FundAsset ID 3
    4		Normal FundAsset	null
    If I add a record that is a Normal FundAsset to Grid 2, it should show up as a new row in Grid 1 with ID 5, that works fine. Now, if I want to add a FundAsset record that is a Subordinate to ID 1, I want it to show up in Grid 2 like this and this works fine:

    Code:
    Grid 2 (DataSource: FundAsset)
    
    FundAsset ID	Name			SubordinateList (hidden attached List of DataSource: FundAsset)
    5		Normal FundAsset	null
    6 		Normal FundAsset	null


    However, what currently happens is this in Grid 1 when adding to Grid 2. It adds a new record to Grid 1 like this:

    Code:
    Grid 1 (DataSource: FundAsset)
    
    FundAsset ID	Name			SubordinateList (hidden attached List of DataSource: FundAsset)
    1		Aggregate FundAsset	Subordinate FundAsset ID 2, Subordinate FundAsset ID 3
    4		Normal FundAsset	null
    5		Normal FundAsset	null
    6		Normal FundAsset	null

    I want the end state of Grid 1 to lool like this when adding subordinate ID 6 to Grid 2, It should just add the subordinate to FundAssetID 1:

    Code:
    Grid 1 (DataSource: FundAsset)
    FundAsset ID	Name			SubordinateList (hidden attached List of DataSource: FundAsset)
    1		Aggregate FundAsset	Subordinate FundAsset ID 2, Subordinate FundAsset ID 3, Subordinate FundAsset ID 6
    4		Normal FundAsset	null
    5		Normal FundAsset	null
    Any suggestions on how to make this happen?

    #2
    I should add that what I'm currently doing when adding FundAssetID 6 to Grid 2 is returning the complete FundAsset 1 with the updated subordinate list including fundAssetID 6 in the response.

    Comment


      #3
      Hi David,
      I'm not entirely sure I understand your question.
      However here's my quick take on it -- hopefully this helps (and if not - try to clarify your question a little, bearing in mind I'm not directly familiar with your app...!)

      Generally speaking:

      If you have a grid bound to a dataSource, when you add a record to it via editing [assuming saveLocally is not set to true], you're really adding a record to the dataSource's underlying data store (be it an SQL table, a client-side javascript array for a client-only datasource, or something else).

      If you have another grid / other grids bound to the same dataSource, the newly added record will show up in any grids where the new record matches the filter criteria applied to the grid.

      This is also true if you add a record to the dataSource directly using APIs other than grid editing of course.

      ---
      Ok -- now in your use case I see this third column on both grids marked as a hidden list.
      Are we talking about an expansion component here? A detail list that shows up when you expand a record?

      I'm not sure if that is the case you're describing -- and if so I'm not sure exactly how you're embedding the detail list in the record, but in short the above general statement still holds true... Each databound grid, whether it's an embedded grid within a record or the "top level" Grid1 / Grid2 will display all the records in the dataSource that match the current criteria.

      Exactly how to make this behave correctly for you depends on your data model. For example if you have a field "parentFundAsset" which does the linking then you'd probably want the top level grid to have criteria including 'parentFundAsset:null' so it only shows records which are not subordinate to some other record.

      That of course makes an assumption about how your app is structured - but hopefully it clarifies the general concept enough to get you going?

      Comment


        #4
        Thanks for the feedback. I knew it would be difficult to convey our requirements clearly. But, adding another criteria clause is exactly what we need to do in order to achieve the effect we want. Such a simple solution and I was dreaming up ways to make it much more complicated.

        Comment

        Working...
        X