Attribute which are depend on other

Hi,

I have a little problem.

I should have two attribute which are depend on each other.
I attached a picture about it.
Two attribute name is Customer type and Customer category.
If the user selects ‘A’ Customer type with a drop-down select, then user can only choose categories which are belong to ‘A’. And the same witch ‘B’ Customer type. If user select ‘B’ for Customer type, then user can not choose ‘apple’ for Customer category. I guess user can’t choose category till user did not chosen a type.

Could you help me how to implement this into my Customer entity? Or how to control it on the edit screen?

Example

Hi,

Take a look at this example project: GitHub - cuba-labs/cascaded-lookups and this topic: Dependent Dropdowns - CUBA.Platform

Thank you so much!

And what if I need a three step dropdown?
So like in your example project, just one plus datasource, dropdown?
Where Country -> City -> Address -> HouseNumber, and on HouseNumber I need the something like in your example.

I tried this query:


select e from myproject$houseNumber e
where e.country.id = :ds$countriesDs
and
where e.city.id = :ds$cityesDs

But I get a “UnsupportedOperationException: Datasource couldn’t depend from two different sources” message.

If you need to depend on multiple datasources, add ItemChangeListener to all of them instead of declarative dependency by “ds$” parameter. In those listeners, refresh the dependent datasource using its refresh() method.

Datasource listeners are explained here: Datasource Listeners - CUBA Platform. Developer’s Manual