Cannot manipulate behaviour of default filter button

Hi guys,

I need some help with manipulating the behavior of the “refresh/search/apply” button for the default filter implementation of JMIX. I want to make the button not clickable if there’s no search term entered inside the text field. I’ve scoured the XSD schemas but couldn’t really find a way to programmatically initialize the button and manipulate its behavior, I’d appreciate your help.

Thanks.

Hi,

Which Jmix version do you use?

Hi,

Still using 1.3.5.

I’m not sure you can easily manipulate filter buttons, but you can prevent loading if some filter conditions are not filled.

@UiController("User.browse")
@UiDescriptor("user-browse.xml")
@LookupComponent("usersTable")
@Route("users")
public class UserBrowse extends StandardLookup<User> {

    @Autowired
    private Filter filter;

    @Autowired
    private Notifications notifications;
    
    @Subscribe(id = "usersDl", target = Target.DATA_LOADER)
    public void onUsersDlPreLoad(final CollectionLoader.PreLoadEvent<User> event) {
        Filter.Configuration currentConfiguration = filter.getCurrentConfiguration();
        LogicalFilterComponent rootLogicalFilterComponent = currentConfiguration.getRootLogicalFilterComponent();
        for (FilterComponent filterComponent : rootLogicalFilterComponent.getFilterComponents()) {
            if (filterComponent instanceof PropertyFilter) {
                PropertyFilter propertyFilter = (PropertyFilter) filterComponent;
                Object value = propertyFilter.getValue();
                if (value == null) {
                    notifications.create(Notifications.NotificationType.WARNING)
                            .withCaption("Fill filter conditions")
                            .show();
                    event.preventLoad();
                }
            }
        }
    }
}

Alternatively you can not to use Generic Filter component but to create your own fixed custom filter using PropertyFilter components. In this case you’ll have full control over UI.