Complex filtering

Hello,

I’m using a table and I want to customise my filter. This table has some custom columns using addGeneratedColumn() method. I attached an example below in which for a list of ingredients I am calculating a subtotal.

ingredientsTable.addGeneratedColumn("subtotal", entity -> {
            Label field = (Label) componentsFactory.createComponent(Label.NAME);
            field.setValue(entity.calculateSubtotal());
            return field;
        });

Let’s say I would like to filter ingredients after the “subtotal” column. I couldn’t find a way to achieve this!

5 Likes

I ran into something similar.
I found this article (CUBA filters - the fast food of business software? – Road to CUBA and beyond...) it doesn’t help though because I have custom columns that need more than a single JOIN in the query to be fetched.

Ideas?

Thanks,
-c

Hi,

If you are talking about the generic Filter component, you can create a custom condition with an arbitrary JPQL. See Add condition > Create new. Of course you cannot use your generated columns in the filter conditions as it operates on the database level. So consider creating a subtotal attribute in your entity and calculating it when the entity is updated, for example using an entity listener.

Hi,

I would need to make querries which would imply multiple joins and as far as I know this is not possible. There is some way to achieve something like this?