Query Filter on groupDataSource

Hi

I have query in datasource like below.

select e from rental$RentalPosition e where
e.rentalstatus >=20 and 
( e.startdate >= :component$dateFrom 
and e.startdate <= :component$dateTo )

I find then I may to use filter mechanism, but I can’t find, how I may to depend on query from component value. When in comonent value is 0 or null I’d like where condition like below

e.rentalstatus >=20 and 
( e.startdate >= :component$dateFrom 
and e.startdate <= :component$dateTo ) 

when in component value is 1 I’d like where condition like below

e.rentalstatus >=20 and 
( e.rentaldate >= :component$dateFrom 
and e.rentaldate <= :component$dateTo )

Is there any way to realize this case in query to groupDataSource ?

Hi,

You can do it programmatically in the screen controller.
Use value change listeners on the components and modify the datasource query as needed, for example:

myField.addValueChangeListener(e -> {
    if (e.getValue().equals(...)) {
        myDs.setQuery("select e from rental$RentalPosition e " +
            "where e.rentalstatus >=20 and " +
            "(e.startdate >= component$dateFrom and e.startdate <= :component$dateTo)");    
    else {
         // ...
    }
});

Ok It’s good way, then I can’t use filter for realize this case ?