Form and grid validation question

Hi,

I have 2 questions concerning validation with grid and form:

1- Can I change the validation behavior? Can I display a message for example in a box in the header. Or in a modal window? Now when the field is not valid, there is only the little icon displayed and the user need to go over it to see the message. Is there also a way to put this icon on the right side of the field?

2- In a grid, is there a way to prevent the user from quitting the field edition when the validation fail? Because now the user can go and edit other fields even in other rows while a field is not valid.

I cannot find any method, property or handler to help me for that.
For my grid, I already tried this:

detailsNodesListGrid.addEditCompleteHandler( new EditCompleteHandler()
        {
            public void onEditComplete( final EditCompleteEvent iEditCompleteEvent )
            {
                if ( !detailsNodesListGrid.validateRow( iEditCompleteEvent.getRowNum() ) )
                {
                    SC.say( "error" );
                }
.....

But this code is never reached…

Any idea?

  1. Once you validate you can always do DynamicForm.getErrors() and display them in a custom manner if you choose. There are some customizations you can do through with setShowErrorStyle(true) and then override getErrorHtml() for the formitems. You can set things to inline, not inline, etc.. It depends on exactly the look-n-feel you want to achieve as to how actually do it.

  2. This is a bit more tricky you need to intercept the editor exit event and if the validation fails cancel the event. As per the javadocs, calling event.cancel() will “Returning false from this method will cancel the default behavior (for example saving the row) and leave the editor visible and focus in this edit cell.”

Thanks for answer #1… I will dig more into that…

But for #2, I still cannot figure out how to do that.
I first tried to add a “onEditFailed” handler, and with that I can display a custom error message. But I am still unable to keep the focus on the edited field. I tried:
“detailsNodesListGrid.startEditing( iEditFailedEvent.getRowNum(), iEditFailedEvent.getColNum(), false );”
In the handler, but this generate a js exception in an infinite loop. I have to kill my browser’s process!

I also tried to add an “EditorExitHandler” as you suggest, but this handler is never reach when the validation failed.
Maybe I have to remove the validator and do my own validation? But if I do that I am loosing the automatic display of the error icon and message in the field…

Actually turns out much easier way, ListGrid.setStopOnErrors(true);

That is working!!! Thanks!!!

I tried this before, but I think I set it on the field and not on the grid itself…