Announcement

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

    #16
    I guess you missed it, but I posted a few posts ago that I am using
    SmartClient Version: v8.2p_2012-05-22/EVAL Deployment

    I just downloaded it today to make sure I had the latest version

    Comment


      #17
      OK thanks, we'll check this out.

      Comment


        #18
        Ok great, thank you for your help. My only guess is that the flow is:

        1. Insert record into queuedOrder.
        2. Try to do a cacheSync by joining new queuedOrder record with new queuedOrderItem record.
        3. Insert record into queuedOrderItem.

        Since the cacheSync is trying to join queuedOrder to queuedOrderItem before the record is inserted into queuedOrderItem there is a problem. Maybe it would work if the cacheSync was ran after both inserts not between both inserts. Just a guess, obviously I will leave it to the experts.

        Comment


          #19
          Ahem, you are quite right, there's no mystery here, that SQL query should be expected to return no rows because there's no orderItems for the order yet.

          You've modified the sample so there's a new "quantity" field on fulfilled by a join to orderItem. At least in this sample, that doesn't make sense - there are multiple items per order each with a distinct quantity value, and you aren't showing a sum.

          However, let's assume in some other app it does make sense (maybe you modify the SQL to use SUM()). In that case, you would want this special fetch operation used as the cacheSyncOperation for *update* but not for *add* (related items will never exist on add).

          Comment


            #20
            Yes, I know that in this sample case this does not make sense. I just used the sample because you asked me to and I knew you would be familiar with it. I assure you that I do have a very real case where this would make sense for an *add* operation. Here is a scenario.

            Lets say I have 3 tables.
            Code:
            person
            	person_id
            	person_name
            
            item
            	item_id
            	item_name
            	item_desc
            	
            
            person_item
            	person_id
            	item_id
            In this case a person can have multiple items and and item can belong to multiple people.


            I have a form where I have a list grid to fetch all the person's items (fetchRelatedData) using a customFetchOperation on the item table. The customFetchOperation does a join on the person_item table. I can get this to work, but when I insert a new item record and want it linked to this person, I cannot get the new item to show up in the grid automatically. I can get both records to insert into both tables, but the cacheSync operation will never work as we discussed. Can you think of another way I can achieve this with SmartGWT? Maybe fire some kind of event in the callback to refresh the grid? Maybe this is just a pretty rare case that hasn't come up before. Again thank you for your help.

            Comment


              #21
              Not following - if you are doing an "add" operation to add a new person, it does not make sense to use a join to person_item as the cacheSyncOperation. That will always fail, just like order and orderItem from the Showcase sample.

              An "add" operation on the person_item might use a cacheSyncOperation to get fields from person like person_name, but this wouldn't fail, because the person and item will actually already exist in the other tables.

              So what cache sync problem arises? The straightforward way of writing this seems to solve this problem.

              Comment


                #22
                No, the person record would already exist. I am adding a brand new item record, and want to simultaneously add a person_item record to link the brand new item to the existing person.

                edit:The grid will already be showing the person's existing items (if any) I would just like the grid to update with the brand new item. I think that I will just use listgrid.invalidateCache() to requery the grid after I do an insert. Would that be the best way?
                Last edited by wolf; 23 May 2012, 10:39.

                Comment


                  #23
                  If you simply do an "add" on a person_item and the person record already exists, then a cacheSyncOperation that involves a join will work fine.

                  Again the problem with your approach with order and orderItem is doing a fetch with a join where no related record yet exists.

                  Comment


                    #24
                    Hello, sorry for the late response. I was able to achieve my desired results by firing an event after both inserts are complete and using listgrid.invalidateCache() to requery the grid.

                    Comment

                    Working...
                    X