Generic Filter - Pin Applied and Clear Values


Is there a way to programmatically apply the ‘pin applied’ and ‘clear values’ options in the filter settings.

We have a number of predefined filters (which the user can combine to produce a detailed filter list) and we would like to automatically pin any current filtered data without the need for the user to open the setting menu and select pin. The current problem is that if the user spends time completing one set of filter data and then forgets to select ‘pin applied’ before selecting an additional predefined filter then they have lost the filter set.


Those actions are stored as attributes of the com.haulmont.cuba.gui.components.filter.FilterDelegateImpl prototype bean. Each filter component has its own instance of this bean.


You can do the following:

  1. Extend this bean with your own class in your project like shown here: Customise Save and Save As action in Filters - #3 от пользователя gorbunkov - CUBA.Platform

  2. Add public getter methods for necessary actions to extended ExtFilterDelegateImpl class.

  3. Inject Filter component in your screen controller

  4. Obtain ExtFilterDelegateImpl instance by calling:

FilterDelegate delegate = ((WebFilter) filter).getDelegate();
ExtFilterDelegateImpl extDelegate = (ExtFilterDelegateImpl) delegate;

Then you will be able to call actions you need (with actionPerform() method).

That’s great. Thanks @AlexBudarov