Announcement

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

    ListGrid fetch for update

    I have a UI that contains a button and a listgrid. When the user clicks on a button, the selected row data of the listgrid may or may not change in the server side. I want to be able to fetch any new data regarding this row without fetching the whole data list. I've tried setting fetch criteria but this replaces the whole data list. Is there any way to just update this one row? I tried calling updatedata like below but it does not reach my ds request processor

    grid.updateData(null, null,{showPrompt:false, cwPK__:id, cwIsFetchByData:true});

    #2
    Call DataSource.fetchData() passing criteria to get the updated record, then create an "update" DSResponse from that and call DataSource.updateCaches().

    Comment


      #3
      Ok. How do I create an "update" dsResponse? I do not see a method to set this in DSResponse object

      Comment


        #4
        This is very simple, in pseudo-code:

        Code:
        myDataSource.updateCaches({
            operationType:"update",
            data: newRecord
        })

        Comment


          #5
          I've put together the code below following some sample from documentation. Just want to double check that this is right. It seems to work.

          Code:
              var criteria = {
                    cwPK__ : id,
                    cwIsFetchByData: true
                 }
                 
                 if(scJsObject.getDataSource()!=null){
                   scJsObject.getDataSource().fetchData(criteria,
                    function (dsResponse, data,request) {
                      
                      request.operationType = "update";
                      var carrier = dsResponse;
                      carrier.data = data;
                       scJsObject.getDataSource().updateCaches(carrier, request);
                    }
                  );
                 }

          Comment


            #6
            Technically it might be cleaner to create an entirely separate response object and set the operation type on that rather than modifying the request and passing that around:

            Code:
                      function (dsResponse, data,request) {
                        var updateResponse = {
                            operationType:"update",
                            data:data
                        }
                        scJsObject.getDataSource().updateCaches(updateResponse);
                      }
            This just ensures that any downstream code doesn't get confused about parameters on the fetch request that don't really apply to the synthetic "update" event.

            Comment

            Working...
            X