Is it possible to leave the grid editor open on a save if there is a validation error?

So for example on

getEditor().addSaveListener(event → {…});

I add some kind of multi-field validation that’s easier than going through the binder (including a database call, etc.). If the validation fails I bring up a notification dialog however when I return from the listener the editor is closed. I would much prefer not to have the user have to redo all their editing from scratch because in some cases it can be more involved. Yes they should probably go to the form view in those cases but is there a way to leave the editor open rather than automatically close it on a validation fail in the saveListener? Or another question could be how can there be an additional hook that I can run validation before the save?

As a bonus when I return the fields keep the value the user last entered for that row in the grid.

Normally it is the Binder that guards it, i.e. if there is validation error, editor is not closed, see

But as createEditor in Grid is protected flow-components/vaadin-grid-flow-parent/vaadin-grid-flow/src/main/java/com/vaadin/flow/component/grid/ at main · vaadin/flow-components · GitHub you can technically extend EditorImpl or implement your Editor and override createEditor. You can get propertyset with BeanPropertySet.get(beanType); utility method.

Interesting. It’s mainly for multi-field validations that may require more extensive time (a wait cursor for example) where some data has to be confirmed before the save can happen.

Thank you.

Or actually let me ask this, how would you do the above? That is a multi-field validation that takes some backend calls and so on and can take upwards of some seconds. Perhaps there is a better alternative?

Personally I would not use Grid’s integrated editor in such cases. Technically one can do bean level validator in Binder as well, but Grid’s editor is not designed for things where synchronous activities take long. Instead I would create some sort of CRUD view. This allows me more freedom of design. I.e. if the expensive validation takes long, I can show some spinner or other thing in the UI for the user to indicate, that things are running and he should wait.

That’s exactly what I’m doing. Except that I’m trying to also offer the ability to edit in the table because in most cases the edits are simple. The unfortunate thing is that even though the edits may be very simple the validations still need to be in place.

That being said what is the recommendation for multi-field validations? Say for example if you select an item from column 1 then the items from column 2 and 3 must within say x and y values. So for example I select 12 volts in column 1 and therefore the watts and ohms (or whatever) need to combined equate a specific formula?

You can use a validation on the binder (not on the field), then validate the entire bean:
Or you can use validation on the field like this:

(I would definitely ‘shield’ the valueChangeListener with a isFromClient to avoid excessive call from the server side)

        event -> {if (event.isFromClient() returningBinding.validate();});```

That’s essentially what I’ve been doing. And it works for anything that is a simpler validation. Thank you.