In general it seems it would be preferable to validate user input on the client side... if you did this you could use the errorString of the itemEditorInstance to show the error to the user without having to wait for the back end, etc. When you do this the error is shown in the cell where the invalid value was entered (it's a pretty nice feedback mechanism).

The following is a code snippet from a DataGrid itemEditEnd event handler where check with a CurrencyValidator to see if user input is valid... if not the errorString is set.

var valueStr:String = event.currentTarget.itemEditorInstance.text; var result:ValidationResultEvent = this.currencyValidator.validate(valueStr, true);
           if(result.results != null && result.results.length > 0)
           {
event.currentTarget.itemEditorInstance.errorString = "Value must be valid currency. ($ddd.cc) dollar sign is optional.";
              event.preventDefault();
           }
           else
           {
               //commit the user edited value...
           }

hth
Scott

grantdotcox wrote:

I have a datagrid with editable cells. When the user changes a value
this is saved to the server. When the server identifies a validation
error on the new data, their change is undone, and a warning message
is shown outside of the grid.

Unfortunately, showing this warning message outside of the grid
(updating the text attribute of a Label), will always cause the
currently editing cell to lose focus. In fact, anything that updates
the screen will do this. This can be annoying, as I want other screen
elements to update etc (without becoming focussed themselves), but not
taking the focus away from what the user is currently editing.

Any ideas?


Reply via email to