filter.setExpanded(false); Not Working

I have created my own filter bar in a browse screen, and would like to set the original filter bar to be collapsed by default.
I’ve tried setting it with filter.setExpanded(false), but that’s not working.

1 Like

Hi Ned,
you probably invoked the filter.setExpanded(false) method from the init(…) method? If so, then try to invoke it from the overridden ready() method, like this:


@Override
public void ready() {
    super.ready();
    filter.setExpanded(false);
}

The problem here is that filter component remembers its collapsed state and restores it on screen opening. This restore happens after the init() method is called, so your explicit filter.setExpanded(false) is overridden by the saved value. The ready() method is invoked after the saved value is applied so it must work.

Perfect. Thanks.

I’m using:


@Override
public void ready() {
    super.ready();
    filter.setCaption("Advanced Filter");
    filter.setExpanded(false);
}

On what I call my “Advanced Filter” (which is really just the regular built-in filter).
It is working, but only partially. When I open the screen it looks (kind of) un-expanded, but then it takes two clicks to open it all the way. Weird. I tried using:


 filter.addExpandedStateChangeListener(e -> {
    if(filter.isExpanded() == false)
        filter.setExpanded(true);
});

to change the number of clicks from two to one, but that really messed things up.

I attached 2 images. One of how it is, and one of what I want (paying attention to “Advanced Filter”). Can you help me here? I really just need it to be closed by default, and open with one click.

filterWhatIWant

filterHowItIs

HI,

this problem is already fixed and the fix will be released in version 6.3.4.

See: https://youtrack.cuba-platform.com/issue/PL-8103