I create a rule for a select action

I created a rule to select an action on a view.
image

When I use the entitypicker and select an entity that doesn’t follow the rule, the button is unable, as the image below shows:

image

But if I do a double click on the same entity, it gets selected, and the rule doesn’t apply to it.
image

Do you have any idea how to solve this problem?

Hi!

Double-clicking a row in the DataGrid triggers the default listener defined in the StandardListView. This listener unfortunately ignores the availability of selectAction and processes the selection itself. This is wrong, I have created an issue to fix this behavior: Default `lookupEnterPress` ignores `selectAction` availability · Issue #4409 · jmix-framework/jmix · GitHub

You can override this behavior in your view as follows:

    @Override
    protected void lookupEnterPress(SupportsEnterPress.EnterPressEvent<?> enterPressEvent) {
        if (getSelectAction().isPresent()
                && getSelectAction().get().isEnabled()) {
            getSelectAction().get().actionPerform(((Component) getLookupComponent()));
        }
    }

It may also make sense to filter the collection in the `DataGrid` by your condition so that rows that can't be selected aren't shown. It all depends on your business requirements.

Thank you for reporting the issue.

Best regards,
Dmitriy

1 Like