Page 1 of 1

FilterEditor dependencies

PostPosted: Fri Feb 03, 2017 12:53 pm
by jvxdev
I have a screen with a table and different filter editors. It works great with minimum configuration. The filter editors are independent and don't depend on each other, right now.

A new requirement is that one filter editor should show the value list in dependence of another filter editor. How to achieve this?

I tried to set an additional condition on the linked cell editor of the databook (which was used as datarow). But this didn't work because the FilterEditor has its own internal datarow?

If I use a simple UIEditor with a custom search row, it's possible with additional condition, but not with FilterEditor?

Re: FilterEditor dependencies

PostPosted: Fri Feb 03, 2017 1:07 pm
by Support@SIB
You're right. There's a difference between manual filtering with UIEditor and custom search DataRow and FilterEditor component.

The FilterEditor component has its internal data row. You have access to this data row:

Code: Select all
editor.getUIResource().getDataRow();

but be careful because the data row only is set after the filter editor got an external data row and a column name.

Anyway. It's easy to solve your requirement, with following code:

Code: Select all
filterMaster.eventFilterValueChanged().addListener(this, "doMasterFilterChanged");

...
public void doMasterFilterChanged() throws ModelException
{
    filterDetail.setValue(null);
       
    DataRow rowDetail = filterDetail.getUIResource().getDataRow();

    ((ILinkedCellEditor)rowDetail.getRowDefinition().
            getColumnDefinition(FilterEditor.SEARCH).
            getDataType().getCellEditor()).
            setAdditionalCondition(new Equals("FILTER_COLUMN", filterMaster.getValue()));
}

We reset the value of the detail filter editor and set an additional filter condition for the list of values. The event is necessary for notification about changes in master filter editor.

If you do manual filtering with an UIEditor and a custom search data row, it's not necessary to use value change listeners because the Condition handles everything automatically. The FilterEditor is a custom component and offers standard search functionality and is customizable.