Announcement

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

    List grid edited value reverts after update

    We have the following scenario in an editable ListGrid -

    1 - edit a field
    2 - navigate to another row and the DataSource update complete successfully
    3 - close edit mode (escape)
    4 - navigate back to previous edited row and double click to edit field again
    5 - close edit mode (escape)
    6 - ERROR OCCURS - the previous unedited value from step 1 now shows in the edit field

    The correct changed value is still persisted by the DataSource but the pre-change value is now showing in the row.

    This is the definition of the grid -

    isc.ListGrid.create({
    ID:"accountsGrid",
    width:600,height:225,
    alternateRecordStyles:true,
    dataSource: accountDS,
    canEdit: true,
    autoFetchData: false,
    fields:accountFields,
    sortField: "AccountName",
    sortDirection: "ascending",
    modalEditing:true
    }

    #2
    See the SmartGWT FAQ (in the SmartGWT Technical Q&A forum - sticky post) about grids not updating. The same applies to your situation even if you're working with SmartClient.

    Comment


      #3
      I read this FAQ -
      "I saved data and my grid/tree/picker didn't update. Why?"

      It says the DS response object must contain the updated data. But the DataSource basically just returns an ACK with the ID of the row but without all the input data. This is probably a common scenario for the updated data to NOT be returned by the datasource (and you already have it in the grid anyway).

      What is the pattern to have the cache refreshed after a successful update when the datasource doesn't echo the updated values?

      Comment


        #4
        See dsRequest.oldValues if you want to simply send back the same data. Note this means that unrelated changes will not be picked up, so the user may be looking at stale data.

        Comment


          #5
          should I return dsRequest.oldValues from function transformResponse?

          Comment


            #6
            Getting warmer maybe. I set dsResponse.data = dsRequest.oldValues in transformResponse. Unfortunately oldValues does NOT include the update the field that was changed.

            So it changes the row back to the pre-update values immediately... Again the update to the backend DataSource completed fine.

            Comment


              #7
              Whack a mole I guess...

              I tried setting dsResponse.data = dsRequest.data which almost does the right thing - BUT only the changed fields exist in dsRequest.data - So now the changed fields are right but the unchanged fields are blank after the update.

              So it will probably work to walk through the dsRequest.data fields and update the individual fields in dsResponse.data while using oldValues for the missing fields.

              Does that sound right - or is there something simpler?

              Comment


                #8
                Server or client-side, you have dsRequest.oldValues and can combine it with dsRequest.data if you choose not to fetch fresh data.

                Comment


                  #9
                  This is what seems to work...

                  transformResponse : function (dsResponse, dsRequest, data) {
                  if (dsRequest.operationType == "update") {
                  dsResponse.data = dsRequest.oldValues; // original values
                  for (var field in dsRequest.data) { // updated fields
                  dsResponse.data[field] = dsRequest.data[field];
                  }
                  return dsResponse;
                  }
                  }

                  Comment

                  Working...
                  X