Can textFields or lookupFields (or anything) be added to the default filter box on a view screen?

I’ve created a separate container in my application that I’ve named “Filter” that has several search fields that update the table. I’ve renamed the default filter container “Advanced Filter.” I’ve been asked to combine them into one simple container called “Filter,” but can’t find a way to do this.

Is it possible?

Here’s an image of what I currently have.

filters image

Hi,

Unfortunately, the filter component doesn’t have an API that allows you to add custom UI components to the filter groupBox.

However, you can try to unwrap the underlying vaadin components and add the custom container to it. Try something like this:


public class MyEntityBrowse extends AbstractLookup {
    
    @Inject
    private Filter filter;

    @Inject
    private ComponentsFactory componentsFactory;

    @Override
    public void ready() {
        super.ready();
        CubaVerticalActionsLayout vFilter = (CubaVerticalActionsLayout) WebComponentsHelper.unwrap(filter);
        CubaGroupBox vGroupBox = (CubaGroupBox) vFilter.getComponent(0);
        CubaVerticalActionsLayout vGroupBoxContent = (CubaVerticalActionsLayout) vGroupBox.getContent();

        Label label = componentsFactory.createComponent(Label.class);
        label.setValue("Test component");

        vGroupBoxContent.addComponent(WebComponentsHelper.unwrap(label), 0);
    }
}

We also created an issue. We will add a method to the filter component that will hide a groupBox border.

Thanks!

This works.

@Override
public void ready() {
super.ready();
filterHbox.setMargin(false, false, true, false);

CubaVerticalActionsLayout vFilter = (CubaVerticalActionsLayout) WebComponentsHelper.unwrap(filter);
CubaGroupBox vGroupBox = (CubaGroupBox) vFilter.getComponent(0);
CubaVerticalActionsLayout vGroupBoxContent = (CubaVerticalActionsLayout) vGroupBox.getContent();

vGroupBoxContent.addComponent(WebComponentsHelper.unwrap((Component) filterHbox), 0);
}

Combined Filter Box

:ticket: See the following issue in our bug tracker:

https://youtrack.cuba-platform.com/issue/PL-8547