Announcement

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

    foreignKey and includeFrom - refetch of displayField

    I have a ds.xml with the following:
    Code:
    <field name="taskName" includeFrom="task.name" />
    <field name="taskId" foreignKey="task.id" displayField="taskName" type="text" >
    In my Master/Details presentation, the ListGrid gets loaded and the taskName comes back in the fetch response along with the taskId as expected and it shows the taskName in the ListGrid for the taskId field which is excellent.

    When I select the row in the ListGrid however the taskName that was retrieved in the original fetch is not used and a 2nd fetch request is made to retrieve the display field for the taskId. Is there something I can do to have the form use the taskName that came back in the record and not perform a 2nd fetch to attempt to retrieve it?

    Original Fetch response:
    Code:
    data:[
           {
               taskName:"Task 1", 
               taskId:"da48c9cfc0a80165006e76b4a013aa22", 
               taskRefCount:9, 
               id:"2e9a2cc445ad4d99bd7d88b531b1b369" 
           }, 
           {
               taskName:"Task 2", 
               taskId:"da4914b3c0a80165006f8d746592cde8", 
               taskRefCount:7, 
               id:"d151930348ba4683ae985ec642361cee" 
           }, 
           {
               taskName:"Task 3", 
               taskId:"410d696bc0a801c9017e5dbf756ecbd5", 
               taskRefCount:1, 
               id:"c1e4486ee12a4efab93b96df6e5d9f69"
           }
       ]
    And when I select a record in the list grid thereby calling editRecord(record) on the form this request is sent to the server:
    Code:
    {
        dataSource:"task", 
        operationType:"fetch", 
        componentId:"isc_OpswiseDynamicForm_0", 
        data:{
            id:"410d696bc0a801c9017e5dbf756ecbd5"
        }, 
        textMatchStyle:"exact", 
        callback:{
            target:[SelectItem ID:isc_SelectItem_2 name:taskId], 
            methodName:"fetchMissingValueReply"
        }, 
        showPrompt:false, 
        oldValues:{
            sysId:"410d696bc0a801c9017e5dbf756ecbd5"
        }, 
        requestId:"task$6273", 
        internalClientContext:{
            dataValue:"410d696bc0a801c9017e5dbf756ecbd5", 
            filterLocally:{
            }
        }, 
        fallbackToEval:false, 
        componentContext:"taskId", 
        lastClientEventThreadCode:"MUP1", 
        bypassCache:true
    }
    I am not sure why the 2nd fetch is being performed when the display field is already contained in the record. Is there anything I can do to use that field and not perform the 2nd fetch? (We sometimes have 4 or 5 fields defined the same way for some datasources so the extra fetch becomes 4 or 5 extra fetches per row selected).

    #2
    Hi stonebranch1,

    you said you were editing the field and not only selecting the row.
    When you edit it, the plain ListGridField text most likely becomes a SelectItem / ComboBoxItem. For the entries of this Item you'll need the requested data.
    I don't know if its possible to delay the fetch until the SelectItem is expanded.

    Best regards,
    Blama

    Comment


      #3
      The ListGrid is not editable and the form item is also marked as "read only" via setCanEdit(Boolean.FALSE);

      Comment


        #4
        Hi stonebranch1,

        I think this comes from the Master/Detail detail form.
        You can see in the 2nd request:

        Code:
        componentId:"isc_OpswiseDynamicForm_0",
        ...
        callback:{
                target:[SelectItem ID:isc_SelectItem_2 name:taskId], 
                methodName:"fetchMissingValueReply"
        },
        .

        If you are never going to use the SelectItem, perhaps switch to an TextItem instead.

        Best regards,
        Blama

        Comment


          #5
          Good suggestion thanks!

          Gave it a try but still does the fetch:
          Code:
              callback:{
                  target:[TextItem ID:isc_TextItem_6 name:taskId], 
                  methodName:"fetchMissingValueReply"
              },

          Comment


            #6
            How about showing taskName in the details instead of taskId?

            Comment


              #7
              This extra fetch should not be necessary with your configuration. We're making a framework change (5.0d and 4.1p branches) which should resolve this.

              Please try the next nightly build and let us know if you still see this problem.

              Thanks
              Isomorphic Software

              EDIT: A correction: This issue didn't appear in the 4.1p branch, just in 5.0d (where it is now resolved).
              Last edited by Isomorphic; 16 May 2014, 12:57.

              Comment


                #8
                Hmmm I am using 4.1p, sorry I forgot to post my level.

                Code Level: SmartClient Version: v9.1p_2014-05-15/Pro Deployment (built 2014-05-15)

                So from your EDIT it looks like the problem and fix is only in 5.0d then?

                Comment


                  #9
                  Hmm - yes - we aren't seeing the problem in 4.1 in our testing.
                  Your setup appears to basically match this showcase example:

                  http://www.smartclient.com/smartgwtee/showcase/#sqlIncludeFrom

                  In that example if you click on a row in the grid to start editing it, you don't kick off an extra fetch in the 4.1p branch (though the same example in 5.0d would).

                  Could you show us client side code to reproduce the problem?
                  It might be easiest to modify that showcase example to better match your application usage so we have something we can run on our end which shows us what's going on for you.

                  Thanks
                  Isomorphic Software

                  Comment


                    #10
                    Difference between that showcase is that in my scenario, it is Master/Details and it is when I select a row in the ListGrid and thereby call editRecord on the DynamicForm that causes the extra fetch. The fetch to retrieve the displayField is originating from the Form not the ListGrid.

                    I will see what I can provide as more example, but basically when calling editRecord on the form and the form has the field for "taskId" (in my case), another fetch is performed to fetch the "taskName" for the specific id in the field "taskId" even though the "taskName" was returned with the record as part of the ListGrid fetch.

                    Comment

                    Working...
                    X