Announcement

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

    Suppressing in-widget update on error

    Newbie one: I have a ListGrid with inline editing turned on. I'm using a datastore linked to my custom PHP back end, so I'm going through the transfomRequest() and processResponse() path.

    It works a treat, only if the user makes an invalid inline edit the widget still keeps the new value. That is, the data store handles the update, the server returns an error which I catch back at the client and present a suitable dialog. But the line in the ListGrid widget still carries the updated value the user typed.

    How do I force the ListGrid to revert its displayed data back to what it was before the user changed it?

    #2
    Use discardEdits(). But consider whether you really want to do this automatically; it's more like something you should allow the user to do, otherwise, you'll be wiping out something the user typed, which may need only minor corrections to become valid.

    Comment


      #3
      Returning to an old thread because I now have to do this bit correctly and I can't work it out. :)

      My DataSource code contains an event handler which is called when the user has edited in the ListGrid, the transformRequest() has called the server with the edits to save, and the server has responded with "no". I don't know what to do here and I can't find any documentation or example which shows the correct procedure. What is currently does is create a new, empty DSResponse object and use it as an argument to processResponse(), in the optimistic hope that this will let the widget finalise the edit. However, I don't think it works like that. :o}

      One option appears to be to find the widget using the data source and call its discardEdits(). But yes, that's rather unfriendly. So how do I get back to a position where the widget is sitting with the user's edits, ready for them to tweak and try to submit again?

      Comment


        #4
        Provide a DSResponse with an error message or validation errors.

        Comment


          #5
          Right, got it, thanks. :)

          For the benefit of anyone doing searches on this forum, the data source error response code looks like this:

          Code:
          DSResponse response = new DSResponse();
          HashMap<String,String> errors = new HashMap<String,String>();
          errors.put( errorField, getFailureDescription() );
          response.setErrors( errors );
          response.setStatus(RPCResponse.STATUS_FAILURE);
          processResponse( requestID, response );
          where 'errorField' and 'getFailureDescription()' are part of my custom server response handling code.

          The ListGrid then needs:

          Code:
          grid.setStopOnErrors(true);
          to make it stop with the failed edit still in focus so the user can have another go.

          Comment

          Working...
          X