Go Back   SmartClient Forums > Smart GWT Technical Q&A
Wiki Register Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 3rd Jul 2012, 21:42
delshole delshole is offline
Registered Developer
 
Join Date: May 2012
Posts: 43
Default 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?
Reply With Quote
  #2  
Old 6th Jul 2012, 08:24
Isomorphic Isomorphic is online now
Administrator
 
Join Date: May 2006
Posts: 30,976
Default

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.
Reply With Quote
  #3  
Old 20th Aug 2012, 23:30
delshole delshole is offline
Registered Developer
 
Join Date: May 2012
Posts: 43
Default

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?
Reply With Quote
  #4  
Old 21st Aug 2012, 09:36
Isomorphic Isomorphic is online now
Administrator
 
Join Date: May 2006
Posts: 30,976
Default

Provide a DSResponse with an error message or validation errors.
Reply With Quote
  #5  
Old 21st Aug 2012, 18:30
delshole delshole is offline
Registered Developer
 
Join Date: May 2012
Posts: 43
Default

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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads
Thread Thread Starter Forum Replies Last Post
MutliUpdate Flag Set. 1 Record Updating ls3674 Smart GWT Technical Q&A 30 12th Jun 2012 16:04
performCustomOperation and Custom Datasource jpappalardo Smart GWT Technical Q&A 5 20th Apr 2012 13:22
Filter on foreign table valbosoft Smart GWT Technical Q&A 22 4th Jan 2012 12:50
List of Strings mikelo6 Smart GWT Technical Q&A 6 23rd Mar 2011 00:42
Assign Value of a ListGrid Cell to a TextItem during onRecordClick Event of the Grid ADA Smart GWT Technical Q&A 4 4th Mar 2009 20:21

© 2010,2011 Isomorphic Software. All Rights Reserved